如何提供此代码。我想简化的 Linq 代码

How to provide this code. Linq code i want simplify

我有这个代码:

dl.db.Table.First(x => x.Id == T.Id).Column1 = "a";
dl.db.Table.First(x => x.Id == T.Id).Column2 = "b"; 
dl.db.Table.First(x => x.Id == T.Id).Column3 = "c"; 
dl.db.Table.First(x => x.Id == T.Id).Column4 = "d"; 
dl.db.Table.First(x => x.Id == T.Id).Column5 = "e"; 

我想做这样的东西,但我做不到

dl.db.Table.First(x => x.Id == T.Id){    
   Column1 = "a";    
   Column2 = "b";    
   Column3 = "c";      
   Column4 = "d";    
   Column5 = "e"; 
}

首先从您的 table 中获取元素并将其存储到一个变量中,然后修改该变量:

var e = dl.db.Table.First(x => x.Id == T.Id);
e.Column1 = "a";
e.Column2 = "b"; 
e.Column3 = "c"; 
e.Column4 = "d"; 
e.Column5 = "e"; 

我认为你唯一的办法就是使用 with 表达式。像这样的事情:

var p1 = new Person("Name1", 5);
var p2 = p1 with { Name = "Name2" };

record Person(string Name, int Age);