我开发的在EF Core中批量执行更新、删除、插入数据的框架Zack.EFCore.Batch已经发布新版,新版增加了对.NET 6的支持,数据批量插入的时候支持ValueConverter,彻底解决了“更新数据的时候,当两列的表达式等价时候出现的The count of columns should be even异常”。
At present, the project has more than 200 stars and has solved more than 40 issues, so it is relatively mature.
Using this library, we can update and delete data in batches in the following ways:
await ctx.DeleteRangeAsync<Book>(b => b.Price > n || b.AuthorName == "zack yang");
await ctx.BatchUpdate<Book>()
.Set(b => b.Price, b => b.Price + 3)
.Set(b => b.Title, b => s)
.Set(b => b.AuthorName,b=>b.Title.Substring(3,2)+b.AuthorName.ToUpper())
.Set(b => b.PubTime, DateTime.Now)
.Where(b => b.Id > n || b.AuthorName.StartsWith("Zack"))
.ExecuteAsync();
Zack.EFCore.Batch支持数据的批量快速插入。
当然,如果您使用SqlSugar、Dapper之类的ORM也可以实现类似的效果,我这个库最大的特色就是它是基于EF Core的扩展,可以复用EF Core的特性。如果您不使用EF Core,那么可以忽略它。
Original author: Yang Zhongke
Original link: mp.weixin.qq.com/s/MYxVGxa_DQnn4XMIDryd9Q
Project address: github.com/yangzhongke/Zack.EFCore.Batch