Best way to delete multiple records in a LINQ query?

后端 未结 10 763
暗喜
暗喜 2021-01-07 17:22

What is the best way to remove multiple records in one go with LINQ?

10条回答
  •  有刺的猬
    2021-01-07 18:23

    maybe its litle late for this answer but today I ran into this demand myself I and I came up with this solution

    CustomerDataContext ctx = new CustomerDataContext("connection string");
    
    ctx.Customers.DeleteAllOnSubmit(ctx.Customers.Where(c => c.Name == "david"));
    
    ctx.SubmitChanges();
    

提交回复
热议问题