Dapper Plus - Bulk Update

Dapper Plus - Bulk Update

 

Description

UPDATE entities using Bulk Operation.

  • Update single
  • Update many
  • Update with relation (One to One)
  • Update with relation (One to Many)

 

Example - Update Single

UPDATE a single entity with Bulk Operation.

DapperPlusManager.Entity().Table("Customers"); 

using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
    connection.BulkUpdate(customers);
}

Try it online

 

Example - Update Many

UPDATE many entities with Bulk Operation.

DapperPlusManager.Entity().Table("Customers");

using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
    connection.BulkUpdate(customers);
}

Try it online

 

Example - Update with relation (One to One)

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

DapperPlusManager.Entity().Table("Suppliers").Identity(x => x.SupplierID);
DapperPlusManager.Entity().Table("Products").Identity(x => x.ProductID);

using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{	
    connection.BulkUpdate(suppliers, x => x.Product);
}

Try it online

 

Example - Update with relation (One to Many)

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

DapperPlusManager.Entity().Table("Suppliers").Identity(x => x.SupplierID);
DapperPlusManager.Entity().Table("Products").Identity(x => x.ProductID);

using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
    connection.BulkUpdate(suppliers, x => x.Products);
}

Try it online

你可能感兴趣的:(database)