I have a table that has a field that is not null and has a default value defined
[CreatedOn] not null default(getdate())
The the property I use in the model for dapper is a nullable DateTime
public DateTime? CreatedOn { get; set; }
If I try to insert, an exception is thrown for trying to insert an null value in a not null field.
cm.Insert<MyObject>(obj); //Throws because CreatedOn == null
What I'm looking for is the default to be set by the database, and to still be able to see that value when I read objects. Because Dapper is passing the value as null, the database throws the error. If I ignore the property then I lose the ability to read it. I'm hoping for a one way ignore, or a flag to let dapper know there will be a default. How does one make this work?