Dapper Plus - Bulk Update
Description
UPDATE entities using Bulk Operation.
Example - Update Single
UPDATE a single entity with Bulk Operation.
DapperPlusManager.Entity<Customer>().Table("Customers");
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
connection.BulkUpdate(customers);
}
Try it: .NET Core | .NET Framework
Example - Update Many
UPDATE many entities with Bulk Operation.
DapperPlusManager.Entity<Customer>().Table("Customers");
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
connection.BulkUpdate(customers);
}
Try it: .NET Core | .NET Framework
Example - Update with relation (One to One)
UPDATE entities with a one to one relation with Bulk Operation.
DapperPlusManager.Entity<Supplier>().Table("Suppliers").Identity(x => x.SupplierID);
DapperPlusManager.Entity<Product>().Table("Products").Identity(x => x.ProductID);
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
connection.BulkUpdate(suppliers, x => x.Product);
}
Try it: .NET Core | .NET Framework
Example - Update with relation (One to Many)
UPDATE entities with a one to many relations with Bulk Operation.
DapperPlusManager.Entity<Supplier>().Table("Suppliers").Identity(x => x.SupplierID);
DapperPlusManager.Entity<Product>().Table("Products").Identity(x => x.ProductID);
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
connection.BulkUpdate(suppliers, x => x.Products);
}
Try it: .NET Core | .NET Framework