Supports .NET6! Framework for Batch Update, Delete, Insert Operations in EF Core: Zack.EFCore.Batch

Supports .NET6! Framework for Batch Update, Delete, Insert Operations in EF Core: Zack.EFCore.Batch

The framework `Zack.EFCore.Batch` for `batch` performing `update`, `delete`, and `insert` operations in `EF Core` has released a new version. The new version adds support for `.NET 6`, supports `ValueConverter` during batch data insertion, and completely solves the `"The count of columns should be even" exception that occurs when two column expressions are equivalent during data update`.

Last updated 12/25/2021 7:23 PM
杨中科
2 min read
Category
EF Core
Tags
.NET C# EF Core ORM Batch Insert

The new version of my framework Zack.EFCore.Batch for performing batch update, delete, and insert operations in EF Core has been released. The new version adds support for .NET 6 and supports ValueConverter during batch data insertion, completely resolving the "The count of columns should be even" exception that occurred when two column expressions were equivalent during data updates.

The project now has over 200 stars and has resolved more than 40 issues, so it is relatively mature.

Using this library, you can perform batch updates and deletes of data as follows:

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 also supports batch fast insertion of data.

Of course, if you use ORMs like SqlSugar or Dapper, you can achieve similar results. The biggest feature of this library is that it is an extension based on EF Core, allowing you to reuse EF Core features. If you are not using EF Core, you can ignore it.

Original author: Zhongke Yang

Original link: https://mp.weixin.qq.com/s/MYxVGxa_DQnn4XMIDryd9Q

Project address: https://github.com/yangzhongke/Zack.EFCore.Batch

Keep Exploring

Related Reading

More Articles