update multiple elements at once LINQ

前端 未结 6 2028
萌比男神i
萌比男神i 2020-12-17 08:42

Is it possible to set property on each element from List using LINQ.

for example:

var users = from u in context.Users where u.Name == \"George\" sele         


        
6条回答
  •  一整个雨季
    2020-12-17 09:24

    If you're interested in in-memory update, that is the database is not going to be updated then you could use

    var users = (from u in context.Users where u.Name == "George" select u).ToList();
    users.ForEach(u => u.MyProp = "Something");
    

提交回复
热议问题