Use linq to generate direct update without select

前端 未结 7 895
感情败类
感情败类 2020-11-29 05:34

G\'day everyone.

I\'m still learning LINQ so forgive me if this is naive. When you\'re dealing with SQL directly, you can generate update commands with conditionals

7条回答
  •  失恋的感觉
    2020-11-29 06:10

    You can use Entity Framework Extensions library, it supports batch update and batch merge, however the library is not free:

    PM > Install-Package Z.EntityFramework.Extensions

    using Z.EntityFramework.Plus;
    
    ...
    
    dc.Products
        .Where(q => q.Type == 1)
        .Update(q => new Product { Count = 0 });
    

提交回复
热议问题