C# Bulk Operations Extend and Overcome SqlBulkCopy Limitations with Must-Have Features


Downloaded more than
0
times !
// Easy to use var bulk = new BulkOperation(connection); bulk.BulkInsert(dt); bulk.BulkUpdate(dt); bulk.BulkDelete(dt); bulk.BulkMerge(dt); // Easy to customize var bulk = new BulkOperation<Customer>(connection); bulk.BatchSize = 1000; bulk.ColumnInputExpression = c => new { c.Name, c.FirstName }; bulk.ColumnOutputExpression = c => c.CustomerID; bulk.ColumnPrimaryKeyExpression = c => c.Code; bulk.BulkMerge(customers);



What's Bulk Operations?

A library that overcomes SqlBulkCopy limitations with Must-Have features



Do you offer consulting services?

Yes, you can contact us for special requests: info@zzzprojects.com



Where can I find online examples?

A lot of examples will be soon available on .NET Fiddle. This feature is under development by our company (ZZZ Projects).

Our achievements

2000+ Customers
75+ Countries
4000+ Requests closed
Over 10 000 000+ download
Over 1 000 000+ daily visitors

What we achieved over the last 4 years has grown beyond our hopes. That motivates us to continue to grow and improve all our projects. Every day, we are committed to listening to our clients to help ease the daily dev workload as much as possible.



Output Identity Value

Overcome SqlBulkCopy limitations and use flexible features to output inserted identity and concurrency column values.

Bulk Operations - Output Identity Example
var bulk = new BulkOperation(connection)

// Output newly inserted identity value after an insert
bulk.ColumnMappings.Add("CustomerID", ColumnMappingDirectionType.Output);

bulk.BulkInsert(dt);

Try it

Insert, Update, Delete, Merge and more...

Bulk Operations is not only about inserting, get more capability over SqlBulkCopy.

  • BulkInsert
  • BulkUpdate
  • BulkDelete
  • BulkMerge (Upsert)
  • BulkSaveChanges
  • BulkSynchronize
Bulk Operations - Methods Example
// Support all type of operations
var bulk = new BulkOperation(connection);
bulk.BulkInsert(dt);
bulk.BulkUpdate(dt);
bulk.BulkDelete(dt);
bulk.BulkMerge(dt);
bulk.BulkSaveChanges(ds);
bulk.BulkSynchronize(dt);

Generic List<> as DataSource

Improve code maintainability by using strongly-typed lambda expression over hard coded string.

  • Use Bulk Operations with Generic List<>
  • Use Bulk Operations with Expando Object
  • Use Lambda Expression for mapping
Bulk Operations - Entity Example
var bulk= new BulkOperation<Customer>(connection);
bulk.DestinationTableName = "Customer";

// Column Columns to Input
bulk.ColumnInputExpression = c => new { c.Code, c.Name };

// Choose Columns to Output
bulk.ColumnOutputExpression = c => c.CustomerID;

// Choose Key to Use
bulk.ColumnPrimaryKeyExpression = c => c.Code;

bulk.BulkMerge(customers);

Bulk Operations from LINQ Query

Perform bulk operations from LINQ Query without loading entities in memory.

  • DeleteFromQuery
  • UpdateFromQuery
Bulk Operations - Batch Delete & Update Example
var bulk = new BulkOperation<Customer>(connection);

// DELETE all customers inactive for more than 2 years
bulk.DeleteFromQuery(
    c => c.Where(x => x.LastLogin < DateTime.Now.AddYears(-2)));

// UPDATE all customers inactive for more than 2 years
bulk.UpdateFromQuery(
    c => c.Where(x => x.Actif && x.LastLogin < DateTime.Now.AddYears(-2)),
    c => new Customer {Actif = false});

AutoMap with Case Insensitive

Sick of not being able to map column because of case sensitivity issue? Use flexible features to customize configuration

  • Auditing
  • Batch Size
  • Case Sensitivity
  • Logging
Bulk Operations - Case Insensitive Example
var bulk = new BulkOperation(connection);
bulk.CaseSensitive = CaseSensitiveType.Insensitive;
bulk.ColumnMappings.Add("cOdE", "Code");
bulk.BulkMerge(dt);