Dapper Plus – Introduction

Library Under Construction (Available at the end of April)

Like Dapper,

Dapper Plus is a NuGet library (Available Soon) that you can add to your project that will extend your `IDbConnection` interface with high efficient Bulk Actions Helpers (Insert, Update, Delete, and Merge).

It can be used with or without Dapper, and it’s compatible with all others Dapper packages.

Example

// CONFIGURE & MAP entity
DapperPlusManager.Entity().Table("Orders").Identity(x => x.ID);

// CHAIN & SAVE entity
connection.BulkInsert(orders)
          .AlsoInsert(order => order.Items);
          .Include(order => order.ThenMerge(order => order.Invoice)
                                 .AsloMerge(invoice => invoice.Items))
          .AlsoMerge(order => order.ShippingAddress);	

Mapper

Dapper Plus Mapper allow to map the conceptual model (Entity) with the storage model (Database) and configure options to perform Bulk Actions.

DapperPlusManager.Entity().Table("Orders")
                                 .Identity(x => x.ID)
                                 .BatchSize(200);

Bulk Actions

Bulk Actions allow to perform a bulk insert, update, delete or merge and include related child items.

connection.BulkInsert(orders, order => order.Items)
          .BulkInsert(invoices, invoice => invoice.Items)
          .BulkMerge(shippingAddresses);

Also Bulk Actions

Also Bulk Actions allow to perform bulk action with a lambda expression using entities from the last Bulk[Action] or ThenBulk[Action] used.

connection.BulkInsert(orders)
          .AlsoInsert(order => order.Items)
          .AlsoInsert(order => order.Invoice)
          .AlsoInsert(order => order.Invoice.Items);

Then Bulk Actions

Then Bulk Actions is similar to Also Bulk Actions but modify entities used for the next bulk action using a lambda expression.

connection.BulkInsert(orders)
          .AlsoInsert(order => order.Items)
          .ThenInsert(order => order.Invoice)
          .ThenInsert(invoice => invoice.Items);

Include Actions

The Dapper Plus Include method allow resolving issues with multiple “ThenBulk[Action]” method.

connection.BulkInsert(orders)
          .Include(x => x.ThenInsert(order => order.Items)
                         .ThenInsert(orderItem => orderItem.Metas))
          .Include(x => x.ThenInsert(order => order.Invoice)
                         .ThenInsert(Invoice => invoice.Items));   	

DB Provider Supported

All major database provider are supported or under development.

  • SQL Server 2008+
  • SQL Azure
  • SQL Compact
  • SQLite
  • MySQL
  • PostgreSQL (Under Development)
  • Oracle (Under Development)