Dapper Plus - Bulk Update

Description

UPDATE entities using Bulk Operation.

Example - Update Single

UPDATE a single entity with Bulk Operation.

  1. DapperPlusManager.Entity<Customer>().Table("Customers");
  2. using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
  3. {
  4. connection.BulkUpdate(customers);
  5. }

Try it: .NET Core | .NET Framework

Example - Update Many

UPDATE many entities with Bulk Operation.

  1. DapperPlusManager.Entity<Customer>().Table("Customers");
  2. using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
  3. {
  4. connection.BulkUpdate(customers);
  5. }

Try it: .NET Core | .NET Framework

Example - Update with relation (One to One)

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

  1. DapperPlusManager.Entity<Supplier>().Table("Suppliers").Identity(x => x.SupplierID);
  2. DapperPlusManager.Entity<Product>().Table("Products").Identity(x => x.ProductID);
  3. using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
  4. {
  5. connection.BulkUpdate(suppliers, x => x.Product);
  6. }

Try it: .NET Core | .NET Framework

Example - Update with relation (One to Many)

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

  1. DapperPlusManager.Entity<Supplier>().Table("Suppliers").Identity(x => x.SupplierID);
  2. DapperPlusManager.Entity<Product>().Table("Products").Identity(x => x.ProductID);
  3. using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
  4. {
  5. connection.BulkUpdate(suppliers, x => x.Products);
  6. }

Try it: .NET Core | .NET Framework