Pignone.Dapper.BulkExtensions 8.0.5

dotnet add package Pignone.Dapper.BulkExtensions --version 8.0.5
                    
NuGet\Install-Package Pignone.Dapper.BulkExtensions -Version 8.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pignone.Dapper.BulkExtensions" Version="8.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pignone.Dapper.BulkExtensions" Version="8.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Pignone.Dapper.BulkExtensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pignone.Dapper.BulkExtensions --version 8.0.5
                    
#r "nuget: Pignone.Dapper.BulkExtensions, 8.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Pignone.Dapper.BulkExtensions@8.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pignone.Dapper.BulkExtensions&version=8.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Pignone.Dapper.BulkExtensions&version=8.0.5
                    
Install as a Cake Tool

Pignone.Dapper.BulkExtensions

NuGet package for extend Dapper operations bulks insert, delete and update.

Index

Overview

This package provides:

  • BulkInsert.
  • BulkDelete.
  • BulkUpdate.

Compatible with .NET 8 and C# 12.

Installation

Via CLI:

dotnet add package Pignone.Dapper.BulkExtensions

Or via PackageReference (e.g. csproj):

<PackageReference Include="Pignone.Dapper.BulkExtensions" Version="*" />

Quick start

BulkInsertAsync example:

using System.Data.SqlClient;
using Pignone.Dapper.BulkExtensions;

// Definition of the class that represents the data
public class User
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
}

// List of data to be inserted
var users = new List<User>
{
    new User { Id = 1, Name = "Alice", Email = "alice@example.com" },
    new User { Id = 2, Name = "Bob", Email = "bob@example.com" }
};

// Mapping dictionary: 
// Key   = Name of the property in the class (T)
// Value = Name of the column in the database (Destination)
var columnMapping = new Dictionary<string, string>
{
    { "Id", "Id" },
    { "Name", "FullName" },
    { "Email", "UserEmail" }
};

// Database connection (IDbConnection)
using var connection = new SqlConnection("YourConnectionString");

// Call to the BulkInsertAsync extension method
await connection.BulkInsertAsync(
    tableName: "UsersTable",
    mappingColumns: columnMapping,
    data: users
);

BulkDeleteAsync example:

using System.Data.SqlClient;
using Pignone.Dapper.BulkExtensions;

// Definition of the class with the necessary properties for deletion
public sealed record UserDeleteDto(int Id);

// List containing only the data (e.g. IDs) you want to batch delete
var usersToDelete = new UserDeleteDto[]
{
    new UserDeleteDto(1),
    new UserDeleteDto(2)
};

// Mapping dictionary: 
// Key   = Name of the property in class T
// Value = Name of the column in the temporary table/database
var columnMapping = new Dictionary<string, string>
{
    { "Id", "Id" }
};

// DELETE command that will JOIN the real table and temporary table
// Important: The temporary table (#TempUsers) will contain the data we pass in the list
string deleteCommand = @"
    DELETE t1
    FROM UsersTable t1
    INNER JOIN #TempUsers t2 ON t1.Id = t2.Id;";

using var connection = new SqlConnection("YourConnectionString");

// Call to the extension method to perform batch delete
await connection.BulkExecuteAsync(
    executeCommandText: deleteCommand,
    temporaryTableName: "#TempUsers",
    tableName: "UsersTable", // Table that has the original mapping columns
    mappingColumns: columnMapping,
    data: usersToDelete
);

BulkUpdateAsync example:

using System.Data.SqlClient;
using Pignone.Dapper.BulkExtensions;

// Definition of the record with the properties for the update
public sealed record UserUpdateDto(int Id, string NewEmail);

// List with the updated data
var usersToUpdate = new UserUpdateDto[]
{
    new UserUpdateDto(1, "new_alice@example.com"),
    new UserUpdateDto(2, "new_bob@example.com")
};

// Mapping dictionary: 
// Key   = Name of the property in the record
// Value = Name of the column in the temporary table/database
var columnMapping = new Dictionary<string, string>
{
    { "Id", "Id" },
    { "NewEmail", "UserEmail" }
};

// UPDATE command that will JOIN the real table and temporary table
// Important: The temporary table (#TempUsers) will contain the newly transferred data
string updateCommand = @"
    UPDATE t1
    SET t1.UserEmail = t2.UserEmail
    FROM UsersTable t1
    INNER JOIN #TempUsers t2 ON t1.Id = t2.Id;";

using var connection = new SqlConnection("YourConnectionString");

// Call to the extension method to perform batch update
await connection.BulkExecuteAsync(
    executeCommandText: updateCommand,
    temporaryTableName: "#TempUsers",
    tableName: "UsersTable", // Table that bases the mapping columns
    mappingColumns: columnMapping,
    data: usersToUpdate
);

References

Contact

For questions and issues, please open an issue in the package repository.

If you think has been helpful to your work, please consider making a small donation to support continued development.

It may be the equivalent of a coffee ☕, but it makes a huge difference on the other side of the screen.

Provider Link
Paypal alt text

If you are Brazilian, you can donate through pix.

Key QR Code
alt text alt text

Your contribution helps ensure that I can continue to improve and support the extension, making it even more useful to the community.

Thank you in advance for considering supporting this project. Your generosity makes all the difference!

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.5 113 3/7/2026
8.0.4 94 3/1/2026
8.0.3 83 3/1/2026
8.0.2 86 3/1/2026
8.0.1 92 2/28/2026
8.0.0 90 2/27/2026

8.0.5
- Code cleanup and structure improvements.
- The BulkDeleteAsync and BulkUpdateAsync methods have been moved to BulkExecuteAsync.

8.0.4
- Code cleanup and structure improvements.
- No behavioral changes.
- No API changes.

8.0.3
- Package Changelog notes.
- Updated project license from MIT to Custom Proprietary License.

8.0.2
- Code cleanup and structure improvements.
- No behavioral changes.
- No API changes.

8.0.1
- Additional configuration options (batch size and timeout).
- Insert performance for large datasets.

8.0.0
- Initial release of Pignone.Dapper.BulkExtensions.
- Support for **BulkInsert** operations.
- Support for **BulkUpdate** operations.
- Support for **BulkDelete** operations.
- Lightweight implementation focused on performance and minimal configuration.