Using LINQ to Update A Property in a List of Entities

前端 未结 5 1208
耶瑟儿~
耶瑟儿~ 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:35

    In addition to Darrelk and mkedobbs, VB.NET Code:

    object.list =
        object.list.Select(Function(x)
                               x.property = If(x.property.Length > 3, x.property.Substring(0, 3), x.property)
                               Return x
                           End Function).ToList()
    

提交回复
热议问题