Dapper Plus - Bulk Merge

MERGE entities using Bulk Operation.

Example - Merge Single

MERGE a single entity with Bulk Operation.

using (var connection = My.ConnectionFactory())
{
    connection.Open();

    connection.BulkMerge(invoice);
}

Example - Merge Many

MERGE many entities with Bulk Operation.

using (var connection = My.ConnectionFactory())
{
    connection.Open();

    connection.BulkMerge(invoices);
}

Example - Merge with relation (One to One)

MERGE entities with a one to one relation with Bulk Operation.

using (var connection = My.ConnectionFactory())
{
    connection.Open();

	connection.BulkMerge(invoices)
		.ThenForEach(x => x.Detail.InvoiceID = x.InvoiceID)
		.ThenBulkMerge(x => x.Detail);
}

Example - Merge with relation (One to Many)

MERGE entities with a one to many relation with Bulk Operation.

using (var connection = My.ConnectionFactory())
{
    connection.Open();

	connection.BulkMerge(invoices)
		.ThenForEach(x => x.Items.ForEach(y => y.InvoiceID = x.InvoiceID))
		.ThenBulkMerge(x => x.Items);
}