Using LINQ to Update A Property in a List of Entities

前端 未结 5 1045
耶瑟儿~
耶瑟儿~ 2021-01-31 13:58

Say I have an entity that looks something like this simple example:

MyEntity 
{
   int property1;
   int property2;
   int property3;
}

Now ass

5条回答
  •  盖世英雄少女心
    2021-01-31 14:13

    Here are two solutions that I found that worked for me.

    result = result.Where(x => (x.property1 = 100) == 100).ToList();
    

    or

    result = result.Select(c => { c.property1 = 100; return c; }).ToList();
    

提交回复
热议问题