Boxit.BulkInsert.SQLServer
2.0.0
dotnet add package Boxit.BulkInsert.SQLServer --version 2.0.0
NuGet\Install-Package Boxit.BulkInsert.SQLServer -Version 2.0.0
<PackageReference Include="Boxit.BulkInsert.SQLServer" Version="2.0.0" />
<PackageVersion Include="Boxit.BulkInsert.SQLServer" Version="2.0.0" />
<PackageReference Include="Boxit.BulkInsert.SQLServer" />
paket add Boxit.BulkInsert.SQLServer --version 2.0.0
#r "nuget: Boxit.BulkInsert.SQLServer, 2.0.0"
#:package Boxit.BulkInsert.SQLServer@2.0.0
#addin nuget:?package=Boxit.BulkInsert.SQLServer&version=2.0.0
#tool nuget:?package=Boxit.BulkInsert.SQLServer&version=2.0.0
BulkInsert
A simple way of doing bulk inserts for SQLServer
Usage:
- First add the
Boxit.BulkInsert.SQLServerpackage to your solution. - Then create a collection of models to add.
- Call
BulkInsert(entities)on your DbContext - Optional: Call configuration methods on the returned
BulkInsertBuilder - Finally call
ExecuteAsync()on theBulkInsertBuilderto run the insert operation
var dbContext = serviceProvider.GetRequiredService<MyDbContext>();
var entities = sonSerializer.Deserialize<MyEntity>(someJsonString);
await dbContext.BulkInsert(entities).ExecuteAsync();
Configuration
Transactions
To include a bulk insert into a transaction, call UseTransaction(SqlTransaction) on the BulkInsertBuilder.
var dbContext = serviceProvider.GetRequiredService<MyDbContext>();
var entities = sonSerializer.Deserialize<MyEntity>(someJsonString);
var transaction = await dbContext.Database.BeginTransactionAsync();
try {
await dbContext.BulkInsert(entities)
.UseTransaction(transaction)
.ExecuteAsync();
// Do more stuff
await transaction.CommitAsync();
} catch (...) {
// Failure handling
await transaction.RollbackAsync();
}
Note
This library is pretty crude as of now and will grow with some love & care.
License
The library is free and open source under the MIT License.
Contributing
Feel free to contribute
code or documentation updates by forking the repo and creating a pull request
feature requests by adding an issue tagged as
feature requestbug reports by adding an issue tagged as
bugWith bug reports it's easiest if you provide a minimal executable example or create a PR which has the Issue-ID inside that contains an added, failing Test. However, this is not needed for bug reports, it just makes it easier for us to understand and reproduce the problem.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.EntityFrameworkCore.SqlServer (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.