Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to provide this code. Linq code i want simplify

I have this code:

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"; 

I want make something like this but i cannot

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

First get the element from your table and store it into a varible, then modify that variable:

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"; 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading