LINQ to Entities how to update a record

后端 未结 4 1128
粉色の甜心
粉色の甜心 2021-02-01 01:58

Okay, so I\'m new to both EF and LINQ. I have figured out how to INSERT and DELETE but for some reason UPDATE seems to escape my grasp.

Here is a sample of my code:

4条回答
  •  情书的邮戳
    2021-02-01 02:37

    //for update

    (from x in dataBase.Customers
             where x.Name == "Test"
             select x).ToList().ForEach(xx => xx.Name="New Name");
    

    //for delete

    dataBase.Customers.RemoveAll(x=>x.Name=="Name");
    

提交回复
热议问题