Dapper Contrib - Data Annotation - Computed

Description

Specifie the property should be excluded from update.

  1. [Table("Invoice")]
  2. public class InvoiceContrib
  3. {
  4. [Key]
  5. public int InvoiceID { get; set; }
  6. public string Code { get; set; }
  7. public InvoiceKind Kind { get; set; }
  8. [Write(false)]
  9. [Computed]
  10. public string FakeProperty { get; set; }
  11. }
  12. using (var connection = My.ConnectionFactory())
  13. {
  14. connection.Open();
  15. var invoices = connection.GetAll<InvoiceContrib>().ToList();
  16. // The FakeProperty is skipped
  17. invoices.ForEach(x => x.FakeProperty += "z");
  18. var isSuccess = connection.Update(invoices);
  19. }