Hi all
I'm overriding NHibernate's PreInsertEventListener in order to set the entity's DateCreated property to DateTime.Now.
Here is my code:
public bool OnPreInsert(PreInsertEvent e)
{
DomainObject domainObject = (DomainObject) e.Entity;
if (domainObject.CreatedById == 0) throw new Exception("The " + domainObject.GetType().Name + " cannot be created if its CreatedById property has not been set.");
domainObject.DateCreated = DateTime.Now;
return false;
}
I am finding that any entity properties set here (for example, the call to DateCreated above) do not find their way into the update SQL created by NHibernate. Does anyone know what gives?
Yes, I have cofirmed that my event listener is being called!
Thanks
David