Dapper Plus – Introduction

Library Under Construction (Available at the end of April)

The Dapper Plus AlsoBulkMerge method allow to MERGE entities in a database table or a view using a lambda expression.

The lambda expression use the entity or the IEnumerable<TEntity> from the last Bulk[Action] or ThenBulk[Action] chained method. (The action can be an insert, update, delete or merge operation).

Dapper Plus – Also Bulk Merge with “One to One” Relation

The Dapper Plus AlsoBulkMerge method allow merging a related item with a “One to One” relation.

Example

Merge an order and also the related invoice.

connection.BulkMerge(order)
          .AlsoBulkMerge(order => order.Invoice);

Merge a list of orders and also the related invoice to every order.

connection.BulkMerge(orders)
          .AlsoBulkMerge(order => order.Invoice);

Dapper Plus – Also Bulk Merge with “One to Many” Relation

The Dapper Plus AlsoBulkMerge method allow merging related items with a “One to Many” relation.

Example

Merge an order and also all related items.

connection.BulkMerge(order)
          .AlsoBulkMerge(order => order.Items);

Merge a list of orders and also all related items to every order.

connection.BulkMerge(orders);
          .AlsoBulkMerge(order => order.Items);

Dapper – Also Bulk Merge and Mixed Relation

The Dapper Plus AlsoBulkMerge method allow merging related item(s) with any relation.

Example

Merge an order, also all related items and also the related invoice.

connection.BulkMerge(order)
          .AlsoBulkMerge(order => order.Items, order => order.Invoice);

Merge a list of orders, also all related items to every order and also the related invoice to every order.

connection.BulkMerge(orders)
          .AlsoBulkMerge(order => order.Items, order => order.Invoice);

Dapper Plus – Also Bulk Merge Chain Action

The Dapper Plus AlsoBulkMerge method allow chaining multiple bulk action methods.

Example

Merge an order and also all related items. Merge an invoice and also all related invoice items.

connection.BulkMerge(order)
          .AlsoBulkMerge(order => order.Items)
          .BulkMerge(invoice)
          .AlsoBulkMerge(invoice => invoice.Items);

Merge a list of orders and also all related items to every order. Merge a list of invoices and also all related items to every invoice.

connection.BulkMerge(orders)
          .AlsoBulkMerge(order => order.Items)
          .BulkMerge(invoices)
          .AlsoBulkMerge(invoice => invoice.Items);