Closed johncbc closed 4 years ago
I noticed the same while working on this PR which adds support to generated properties in Dapper.FluentMap.
In addition to @johncbc DatabaseGeneratedAttribute
, my suggestion is to modify IPropertyResolver
by returning our own PropertyInfo
(same as IKeyPropertyResolver
's KeyPropertyInfo
) instead of System.Reflection.PropertyInfo
, so we can mark generated properties and ignore them on insert and update.
Good suggestion. I'll look into it.
Fixed in #201
It seems common to have a few places where columns may be auto-generated by the database.
E.g. https://fluentmigrator.github.io/articles/db-functions.html
I noticed that the KeyPropertyInfo sets an IsGenerated() flag, which is checked on Insert - BuildInsertQuery.
I hacked together the following in Insert.cs in Dommel source, but not sure if it would be the desired approach.