I am creating an ASP.NET MVC3 application using NHIBERNATE. I have a base class Entity that is used to capture some audit information like CreatedBy, CreatedOn, UpdatedBy, UpdatedOn, etc. These properties should get populated automagically whenever a derived class is created and persisted/updated.
As the Entity type and all other types are defined in the DOMAIN Assembly, What would be the best way to percolate USER information from Web project to DOMAIN to populate the information in Entity base class
EDIT
Further,
- Currently, i define all properties as public virtual, so how do I implement them so that the dates/userId are created on the fly at the time of persistence.
- I want Base class properties to persist in each table for derived concrete classes (table per concrete class). How do i specify it using FLUENT NHIBERNATE (I am not using Automapping)
Use an Interceptor when you open the session:
File: AuditInterceptor.cs