Skip to content

ppx80/BHulk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BHulk WIP

Build Status GitHub license

BHulk is a simple library to update a huge amount of records. Under the hood, use EF.Core ExecuteSqlCommandAsync, and dynamically build a query like this:

UPDATE Orders SET OrderCode = {0} WHERE Id IN ({1}, {2}, ....., {N})

Usage

Performs the update for the given list of primary key values in 1000-line steps at a time

var update = BHulk<Order>
                .UseContext(() => ContextFactory())
                .Set(o => o.OrderCode, "test")
                .Set(o => o.Status, OrderStatus.Executed)
                .Set(o => o.ModifiedDate, DateTime.UtcNow)
                .For(Enumerable.Range(1,10000).ToArray())
                .InStepOf(1000);

var affectedRows = await update.ExecuteAsync();      

Uses a predicate for searching the primary keys and then perform the update in 1000-line steps at a time

var update = BHulk<Order>
                .UseContext(() => ContextFactory())
                .Set(o => o.Status, OrderStatus.Executed)
                .Set(o => o.ModifiedDate, DateTime.UtcNow)
                .For(o => o.Status == OrderStatus.Pending)
                .InStepOf(1000);

var affectedRows = await update.ExecuteAsync();      

Releases

No releases published

Packages

No packages published

Languages