Dapper Contrib - Update

Description

UPDATE a single or many entities.

Example - Update Single

UPDATE a single entitiy.

  1. using (var connection = My.ConnectionFactory())
  2. {
  3. connection.Open();
  4. var isSuccess = connection.Update(new Invoice { InvoiceID = 1, Code = "Update_Single_1"});
  5. }

Example - Update Many

UPDATE many entities.

  1. using (var connection = My.ConnectionFactory())
  2. {
  3. connection.Open();
  4. var list = new List<Invoice>()
  5. {
  6. new Invoice {InvoiceID = 1, Code = "Update_Many_1"},
  7. new Invoice {InvoiceID = 2, Code = "Update_Many_2"},
  8. new Invoice {InvoiceID = 3, Code = "Update_Many_3"}
  9. };
  10. var isSuccess = connection.Update(list);
  11. }