R – Database Generated Date on Insert with NHibernate


I am a newbie with NHibernate, so please bear with me.

Let's imagine, i have a property for CreatedDate, and i wanted it to be filled with the sql server datetime value.

The possible solution that i found out is, to mark this property as "generated=always" with "insert=false" and "update=false", and then set the default value for the CreatedDate on sql server level (i mean the database column), to "Getdate()".

Is this the right approach? Thanks for your time, any suggestion will be well appreciated.

Best Solution

You need an nHibernate Audit Interceptor:


Related Question