Ignore property on model property

Elisabeth picture Elisabeth · Oct 31, 2013 · Viewed 26.9k times · Source

How can I ignore a property on my model using dapper/dapper extensions/dapper rainbow or any

of those dapper libraries?

Answer

Ben Collins picture Ben Collins · Nov 5, 2014

Dapper.Contrib has built-in support for marking a column as computed: add ComputedAttribute to allow support for computed columns on Insert. Here's how it works:

class MyModel
{
  public string Property1 { get; set; }

  [Computed]
  public int ComputedProperty { get; set; }
}

Properties marked with the Computed attribute will be ignored on inserts.