RepoDb.SqlServer.BulkOperations
1.15.0
Prefix Reserved
dotnet add package RepoDb.SqlServer.BulkOperations --version 1.15.0
NuGet\Install-Package RepoDb.SqlServer.BulkOperations -Version 1.15.0
<PackageReference Include="RepoDb.SqlServer.BulkOperations" Version="1.15.0" />
<PackageVersion Include="RepoDb.SqlServer.BulkOperations" Version="1.15.0" />
<PackageReference Include="RepoDb.SqlServer.BulkOperations" />
paket add RepoDb.SqlServer.BulkOperations --version 1.15.0
#r "nuget: RepoDb.SqlServer.BulkOperations, 1.15.0"
#:package RepoDb.SqlServer.BulkOperations@1.15.0
#addin nuget:?package=RepoDb.SqlServer.BulkOperations&version=1.15.0
#tool nuget:?package=RepoDb.SqlServer.BulkOperations&version=1.15.0
RepoDb.SqlServer.BulkOperations
High-performance bulk operations for RepoDB on SQL Server. Process millions of rows in a single pass — up to 90% faster than row-by-row or batch operations.
Important Pages
- GitHub Home — core library and source code.
- Website — full documentation, API reference, and blog.
Core Features
Community
- GitHub Issues — bug reports and feature requests.
- StackOverflow — technical questions.
- Microsoft Teams — live Q&A.
- X / Twitter — news and updates.
License
Apache-2.0 — Copyright © 2020 Michael Camara Pendon
Installation
Install-Package RepoDb.SqlServer.BulkOperations
Then initialize the bootstrapper once at application startup:
RepoDb.SqlServerBootstrap.Initialize();
Or visit the installation page for more options.
Special Arguments
qualifiers — defines the fields used in the WHERE clause for delete, merge, and update operations. Defaults to the primary key or identity column.
isReturnIdentity — when enabled, newly generated identity values are written back to the entity objects after the operation completes.
usePhysicalPseudoTempTable — controls whether a physical temp table or a session-scoped #TempTable is used internally. Defaults to session-scoped.
Identity Setting Alignment
When isReturnIdentity is enabled, RepoDB adds an internal __RepoDb_OrderColumn to the pseudo-temporary table. This column preserves the original index of each entity in the IEnumerable<T> collection, ensuring that identity values are mapped back to the correct objects after the bulk operation completes.
Async Methods
Every synchronous operation has a corresponding Async overload.
Caveats
RepoDB automatically sets SqlBulkCopyOptions.KeepIdentity for BulkDelete, BulkMerge, and BulkUpdate when no qualifiers are provided and the target table has an IDENTITY primary key column.
These operations require the connected user to have CREATE TABLE permission in the target database, since a pseudo-temporary table is created internally during execution.
BulkDelete
Deletes a list of entities or primary keys from the database in bulk. Returns the number of deleted rows.
BulkDelete via PrimaryKeys
using (var connection = new SqlConnection(ConnectionString))
{
var primaryKeys = new object[] { 10045, ..., 11902 };
var rows = connection.BulkDelete<Customer>(primaryKeys);
}
Or:
using (var connection = new SqlConnection(ConnectionString))
{
var primaryKeys = new object[] { 10045, ..., 11902 };
var rows = connection.BulkDelete("Customer", primaryKeys);
}
BulkDelete via DataEntities
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkDelete<Customer>(customers);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkDelete<Customer>(customers, qualifiers: e => new { e.LastName, e.DateOfBirth });
}
Or via table-name:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkDelete("Customer", customers);
}
Or via table-name with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkDelete("Customer", customers, qualifiers: Field.From("LastName", "DateOfBirth"));
}
BulkDelete via DataTable
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var rows = connection.BulkDelete("Customer", table);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var rows = connection.BulkDelete("Customer", table, qualifiers: Field.From("LastName", "DateOfBirth"));
}
BulkDelete via DbDataReader
using (var connection = new SqlConnection(ConnectionString))
{
using (var reader = connection.ExecuteReader("SELECT * FROM [dbo].[Customer];"))
{
var rows = connection.BulkDelete("Customer", reader);
}
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
using (var reader = connection.ExecuteReader("SELECT * FROM [dbo].[Customer];"))
{
var rows = connection.BulkDelete("Customer", reader, qualifiers: Field.From("LastName", "DateOfBirth"));
}
}
BulkInsert
Inserts a list of entities into the database in bulk. Returns the number of inserted rows.
BulkInsert via DataEntities
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkInsert<Customer>(customers);
}
Or via table-name:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkInsert("Customer", customers);
}
BulkInsert via DataTable
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var rows = connection.BulkInsert("Customer", table);
}
BulkInsert via DbDataReader
using (var connection = new SqlConnection(ConnectionString))
{
using (var reader = connection.ExecuteReader("SELECT * FROM [dbo].[Customer];"))
{
var rows = connection.BulkInsert("Customer", reader);
}
}
BulkMerge
Upserts a list of entities in bulk — inserts new rows and updates existing ones based on the defined qualifiers. Returns the number of affected rows.
BulkMerge via DataEntities
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkMerge<Customer>(customers);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkMerge<Customer>(customers, qualifiers: e => new { e.LastName, e.DateOfBirth });
}
Or via table-name:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkMerge("Customer", customers);
}
Or via table-name with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkMerge("Customer", customers, qualifiers: Field.From("LastName", "DateOfBirth"));
}
BulkMerge via DataTable
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var rows = connection.BulkMerge("Customer", table);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var rows = connection.BulkMerge("Customer", table, qualifiers: Field.From("LastName", "DateOfBirth"));
}
BulkMerge via DbDataReader
using (var connection = new SqlConnection(ConnectionString))
{
using (var reader = connection.ExecuteReader("SELECT * FROM [dbo].[Customer];"))
{
var rows = connection.BulkMerge("Customer", reader);
}
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
using (var reader = connection.ExecuteReader("SELECT * FROM [dbo].[Customer];"))
{
var rows = connection.BulkMerge("Customer", reader, qualifiers: Field.From("LastName", "DateOfBirth"));
}
}
BulkUpdate
Updates existing rows in the database in bulk. Returns the number of updated rows.
BulkUpdate via DataEntities
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkUpdate<Customer>(customers);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkUpdate<Customer>(customers, qualifiers: e => new { e.LastName, e.DateOfBirth });
}
Or via table-name:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkUpdate("Customer", customers);
}
Or via table-name with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkUpdate("Customer", customers, qualifiers: Field.From("LastName", "DateOfBirth"));
}
BulkUpdate via DataTable
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var rows = connection.BulkUpdate("Customer", table);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var rows = connection.BulkUpdate("Customer", table, qualifiers: Field.From("LastName", "DateOfBirth"));
}
BulkUpdate via DbDataReader
using (var connection = new SqlConnection(ConnectionString))
{
using (var reader = connection.ExecuteReader("SELECT * FROM [dbo].[Customer];"))
{
var rows = connection.BulkUpdate("Customer", reader);
}
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
using (var reader = connection.ExecuteReader("SELECT * FROM [dbo].[Customer];"))
{
var rows = connection.BulkUpdate("Customer", reader, qualifiers: Field.From("LastName", "DateOfBirth"));
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.9)
- RepoDb (>= 1.15.0)
- RepoDb.SqlServer (>= 1.15.0)
-
net10.0
- RepoDb (>= 1.15.0)
- RepoDb.SqlServer (>= 1.15.0)
-
net8.0
- RepoDb (>= 1.15.0)
- RepoDb.SqlServer (>= 1.15.0)
-
net9.0
- RepoDb (>= 1.15.0)
- RepoDb.SqlServer (>= 1.15.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on RepoDb.SqlServer.BulkOperations:
| Package | Downloads |
|---|---|
|
2doit.NopCommerce.Services
2doit NopCommerce API Services/Libraries |
|
|
NGen
Package Description |
|
|
CafeLib.Data.Sources.SqlServer
SQL Server data source packge |
|
|
Gasolutions.Core.GenericRepository.RepoDB
Interface and Implementation for a generic repository using RepoDB. |
|
|
Fx.Data.SQL
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on RepoDb.SqlServer.BulkOperations:
| Repository | Stars |
|---|---|
|
TortugaResearch/DotNet-ORM-Cookbook
This repository is meant to show how to perform common tasks using C# with variety of ORMs.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.15.0 | 0 | 7/18/2026 |
| 1.15.0-telemetry | 0 | 7/18/2026 |
| 1.14.0 | 2,396 | 6/28/2026 |
| 1.13.2-alpha1 | 1,892 | 2/26/2024 |
| 1.13.1 | 333,506 | 3/16/2023 |
| 1.13.0 | 17,052 | 11/2/2022 |
| 1.13.0-beta1 | 822 | 10/25/2022 |
| 1.13.0-alpha3 | 808 | 10/24/2022 |
| 1.13.0-alpha2 | 799 | 10/6/2022 |
| 1.13.0-alpha1 | 847 | 9/17/2022 |
| 1.1.6 | 57,379 | 2/18/2022 |
| 1.1.6-beta2 | 1,513 | 12/13/2021 |
| 1.1.6-beta1 | 964 | 9/27/2021 |
| 1.1.5 | 33,745 | 9/23/2021 |
| 1.1.5-beta2 | 972 | 9/17/2021 |
| 1.1.5-beta1 | 906 | 9/4/2021 |
| 1.1.4 | 39,008 | 2/6/2021 |
| 1.1.3 | 5,188 | 1/13/2021 |
| 1.1.2 | 2,254 | 12/30/2020 |