Git Product home page Git Product logo

bulk-operations's Introduction

Improve SQL insert, update, delete and merge performance and overcome SqlBulkCopy limitations

  • Auditing
  • Case Sensitivity
  • Entity DataSource / Lambda Mapping
  • Output Value
  • And more...
Scalable

SQL Server - Benchmarks

Operations 1,000 Rows 10,000 Rows 100,000 Rows 1,000,000 Rows
Insert 6 ms 25 ms 200 ms 2,000 ms
Update 50 ms 80 ms 575 ms 6,500 ms
Delete 45 ms 70 ms 625 ms 6,800 ms
Merge 65 ms 160 ms 1,200 ms 12,000 ms

As fast as SqlBulkCopy for insert but with way more capabilities

Extensible

Support Multiple SQL Providers:

  • SQL Server 2008+
  • SQL Azure
  • SQL Compact
  • MySQL
  • SQLite
  • PostgreSQL
  • Oracle

Support Multiple Datasources:

  • Entity
  • DataTable
  • DataRow
  • DataReader
  • DataSet
  • Expando Object

Download

download

PM> Install-Package Z.BulkOperations

* PRO Version unlocked for the current month

Stay updated with latest changes

Twitter Follow Facebook Like

Insert - Output Identity Value

Problem

You need to output newly generated identity value but SqlBulkCopy do not support it.

Solution

Map your identity column with output direction.

var bulk = new BulkOperation(connection);

bulk.ColumnMappings.Add("CustomerID", ColumnMappingDirectionType.Output);
// ... mappings ...

bulk.BulkInsert(dt);
Flexibility

You can also output concurrency column (Timestamp) or any other column values. All kind of mapping direction are supported including "Formula" to use with a SQL Formula.

Entity DataSource / Lambda Mapping

Problem

You have a list of entity to insert but SqlBulkCopy doesn't support entity and lambda expression mapping.

Solution

Create a generic bulk operations with your entity type and use lambda expression for your column input, output and primary key mapping.

var bulk = new BulkOperation<Customer>(connection);

bulk.ColumnInputExpression = c => new { c.Name,  c.FirstName };
bulk.ColumnOutputExpression = c => c.CustomerID;
bulk.ColumnPrimaryKeyExpression = c => c.Code;

bulk.BulkMerge(customers);
Maintainability

Get rid of hardcoded string and use strongly-typed lambda expressions.

AutoMapping & Case Sensitivity

Problem

You have a DataTable which columns name match name in the database but SqlBulkCopy throw an error because name match are case insensitive.

Solution

Turn off case sensitivity with IsCaseSensitive property.

var bulk = new BulkOperation(connection);

bulk.IsCaseSensitive = false;

bulk.BulkMerge(dt);
Readability

Remove useless code which would have required to create your own mapping and keep the essentials.

Support

Contact our outstanding customer support for any request. We usually answer within the next business day, hour, or minutes!

PRO

PRO Version unlocked for the current month

Features PRO Version
Bulk Insert Yes
Bulk Update Yes
Bulk Delete Yes
Bulk Merge Yes
Bulk SaveChanges Yes
Bulk Synchornize Yes
DeleteFromQuery Yes
UpdateFromQuery Yes
Commercial License Yes
Royalty-Free Yes
Support & Upgrades (1 year) Yes

Learn more about the PRO Version

Contribute

The best way to contribute is by spreading the word about the library:

  • Blog it
  • Comment it
  • Fork it
  • Star it
  • Share it

A HUGE THANKS for your help.

More Projects

Entity Framework

Bulk Operations

Expression Evaluator

Utilities

Need more info? [email protected]

Contact our outstanding customer support for any request. We usually answer within the next business day, hour, or minutes!

bulk-operations's People

Contributors

jonathanmagnan avatar lempireqc avatar stgelaisalex avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.