views:

111

answers:

2

I am trying to map an entity in NHibernate, that should have an Updated column. This should be the DateTime when the entity was last written to the database (either created or updated). I'd like NHibernate to control the update of the column, so I don't need to remember to set a property to the current time before updating.

Is there a built-in feature in NHibernate, that can handle this for me ?

+1  A: 

You can have a look here or you can create an interceptor to do the job. About them here

Sly
+1  A: 

Use a Listener that implements IPreUpdateEventListener and IPreInsertEventListener. This article explains how. Note that this uses the user's time and that may not be appropriate for your application.

Jamie Ide