Dapper Plus - Actions

Bulk Actions

The Dapper Plus Bulk[Action] method allow to [Action] entities in a database table or a view

Example

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

Also Bulk Actions

The Dapper Plus AlsoBulk[Action] method allow to [Action] entities in a database table or a view using a lambda expression.

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

Example

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

Then Bulk Actions

The Dapper Plus ThenBulk[Action] method allow to [Action] entities in a database table or a view using a lambda expression.

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

Example

connection.BulkInsert(orderTransaction)
.ThenBulkInsert(transaction => transaction.order)
.ThenBulkInsert(order => order.Invoice);

Include Actions

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

Example

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));

Transaction

All Dapper Plus extension methods are also available on the IDbTransaction interface

Example

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