更新时间:2023-02-13 11:28:19
您可以更改顺序,然后使用ForEach运算符:
You can change the order, then use the ForEach operator:
tickets
.Where(x => x.Name == "Beach")
.ToList()
.ForEach(x => { x.Selected = true; });
注意:
ToList()
-请参见 LINQ相当于IEnumerable< T> foreach(x in list)
C#循环SubmitChanges()
才能保留更改.ToList()
is needed because IEnumerable doesn't support ForEach in Linq - see LINQ equivalent of foreach for IEnumerable<T>foreach(x in list)
C# loop SubmitChanges()
in order to persist your changes.