Dapper does not provide a formal API for performing bulk inserts or other bulk operations. However, those operations are possible using a third-party library called Dapper Plus.
Dapper Plus library is a comprehensive .NET library that provides a unified API for working with different databases, such as SQL Server, MySQL, SQLite, Oracle, PostgreSQL, etc.
- It offers features like bulk operations, object mapping, and much more.
- The library allows you to write less code and get more performance out of your database operations.
- It is easy to configure, which helps make development faster and simpler.
- Dapper Plus library also supports asynchronous programming, allowing developers to use the await/async keywords for asynchronous data writing.
Dapper Plus - Methods
|BulkInsert||Execute a Bulk Operation for inserting thousands of entities.|
|BulkUpdate||Execute a Bulk Operation for updating thousands of entities.|
|BulkDelete||Execute a Bulk Operation for deletiong thousands of entities|
Dapper Plus - Getting Started
To use Dapper Plus in your application, you need to install the NuGet Package
This library is not free but is the fastest way to save your data. In addition, you save development time (so money) as you don't have to write any SQL statements and unit tests for those bulk operations.
You can find more information on their official website
Like Dapper, Dapper Plus extends your
IDbConnection interface but with high-performance bulk operations:
connection.BulkInsert(customers); connection.BulkUpdate(customers); connection.BulkDelete(customers); connection.BulkMerge(customers);