Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zzzprojects/Bulk-Operations
C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
https://github.com/zzzprojects/Bulk-Operations
csharp dotnet sqlbulkcopy
Last synced: about 2 months ago
JSON representation
C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
- Host: GitHub
- URL: https://github.com/zzzprojects/Bulk-Operations
- Owner: zzzprojects
- Created: 2016-02-11T20:26:54.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-22T01:45:59.000Z (2 months ago)
- Last Synced: 2024-10-23T02:24:32.514Z (2 months ago)
- Topics: csharp, dotnet, sqlbulkcopy
- Language: C#
- Homepage: https://bulk-operations.net
- Size: 356 KB
- Stars: 142
- Watchers: 12
- Forks: 36
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - zzzprojects/Bulk-Operations - C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite. (C\#)
README
## What's Bulk Operations?
Bulk Operations is a library that allows to overcomes SqlBulkCopy limitations by adding high-performance bulk operations to insert, update, delete and merge.##### 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
- OracleSupport Multiple Datasources:
- Entity
- DataTable
- DataRow
- DataReader
- DataSet
- Expando Object```
PM> Install-Package Z.BulkOperations
```_* PRO Version unlocked for the current month_
## Insert - Output Identity Value
##### Problem
You need to output the newly generated identity value, but SqlBulkCopy does 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 kinds of mapping directions are supported, including "Formula" to use with a SQL Formula.## Entity DataSource / Lambda Mapping
##### Problem
You have a list of entities to insert, but SqlBulkCopy doesn't support entity and lambda expression mapping.##### Solution
Create generic bulk operations with your entity type and use lambda expression for your column input, output, and primary key mapping.```csharp
var bulk = new BulkOperation(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 throws an error because name matches are case insensitive.##### Solution
Turn off case sensitivity with **IsCaseSensitive** property.```csharp
var bulk = new BulkOperation(connection);bulk.IsCaseSensitive = false;
bulk.BulkMerge(dt);
```##### Readability
Remove useless code that would have required you to create your own mapping and keep the essentials.## PRO
_PRO Version unlocked for the current month_Features | [PRO Version](https://bulk-operations.net/#pro)
-------- | :-------------: |
Bulk Insert | Yes
Bulk Update | Yes
Bulk Delete | Yes
Bulk Merge | Yes
Bulk SaveChanges | Yes
Bulk Synchronize | Yes
DeleteFromQuery | Yes
UpdateFromQuery | Yes
Commercial License | Yes
Royalty-Free | Yes
Support & Upgrades (1 year) | YesLearn more about the **[PRO Version](https://bulk-operations.net/#pro)**
## Contribute
The best way to contribute is by **spreading the word** about the library:
- Blog it
- Comment it
- Star it
- Share it
A **HUGE THANKS** for your help.## More Projects
- Projects:
- [EntityFramework Extensions](https://entityframework-extensions.net/)
- [Dapper Plus](https://dapper-plus.net/)
- [C# Eval Expression](https://eval-expression.net/)
- Learn Websites
- [Learn EF Core](https://www.learnentityframeworkcore.com/)
- [Learn Dapper](https://www.learndapper.com/)
- Online Tools:
- [.NET Fiddle](https://dotnetfiddle.net/)
- [SQL Fiddle](https://sqlfiddle.com/)
- [ZZZ Code AI](https://zzzcode.ai/)
- and much more!To view all our free and paid projects, visit our website [ZZZ Projects](https://zzzprojects.com/).