Dapper Contrib - Insert

Description

INSERT a single or many entities.

Example - Insert Single

INSERT a single entitiy.

  1. using (var connection = My.ConnectionFactory())
  2. {
  3. connection.Open();
  4. var identity = connection.Insert(new InvoiceContrib {Kind = InvoiceKind.WebInvoice, Code = "Insert_Single_1"});
  5. }

Example - Insert Many

INSERT many entities.

  1. using (var connection = My.ConnectionFactory())
  2. {
  3. connection.Open();
  4. var list = new List<InvoiceContrib>
  5. {
  6. new InvoiceContrib {Kind = InvoiceKind.WebInvoice, Code = "Insert_Many_1"},
  7. new InvoiceContrib {Kind = InvoiceKind.WebInvoice, Code = "Insert_Many_2"},
  8. new InvoiceContrib {Kind = InvoiceKind.StoreInvoice, Code = "Insert_Many_3"}
  9. };
  10. var identity = connection.Insert(list);
  11. }