Dapper Plus

What’s Dapper Plus?

Dapper Plus extends the IDbConnection interface with Bulk Operations methods:

  • Bulk Insert
  • Bulk Update
  • Bulk Delete
  • Bulk Merge

This library is the fastest way to perform saving operations in a database.

Official Website: http://dapper-plus.net/

Installation

Dapper Plus is installed through NuGet: https://www.nuget.org/packages/Z.Dapper.Plus/

This library is NOT FREE, but a monthly trial is available at the start of every month.

Requirement

Dapper Plus is compatible with all major database provider:

  • SQL Server 2008+
  • SQL Azure
  • SQL Compact
  • Oracle
  • MySQL
  • SQLite
  • PostgreSQL

Methods

Dapper Plus extend your IDbConnection interface with multiple methods:

  1. // STEP MAPPING
  2. DapperPlusManager.Entity<Supplier>().Table("Suppliers").Identity(x => x.SupplierID);
  3. DapperPlusManager.Entity<Product>().Table("Products").Identity(x => x.ProductID);
  4. // STEP BULKINSERT
  5. using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
  6. {
  7. connection.BulkInsert(suppliers).ThenForEach(x => x.Products.ForEach(y => y.SupplierID = x.SupplierID)).ThenBulkInsert(x => x.Products);
  8. }
  9. // STEP BULKUPDATE
  10. using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
  11. {
  12. connection.BulkUpdate(suppliers, x => x.Products);
  13. }
  14. // STEP BULKMERGE
  15. using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
  16. {
  17. connection.BulkMerge(suppliers).ThenForEach(x => x.Products.ForEach(y => y.SupplierID = x.SupplierID)).ThenBulkMerge(x => x.Products);
  18. }
  19. // STEP BULKDELETE
  20. using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
  21. {
  22. connection.BulkDelete(suppliers.SelectMany(x => x.Products)).BulkDelete(suppliers);
  23. }

Try it: .NET Core | .NET Framework