O'Reilly logo

NHibernate 3.0 Cookbook by Jason Dentler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating and changing stamping entities

Although it doesn't track the full history of an entity, another option for auditing is to record information about the entity's creation and the most recent change directly in the entity. In this recipe, I'll show you how to use NHibernate's events to create and change stamp entities.

How to do it...

  1. Create a new class library project named Changestamp.
  2. Add a reference to NHibernate.dll.
  3. Create an interface named IStampedEntity with the following code:
    public interface IStampedEntity
    {
    
      string CreatedBy { get; set; }
      DateTime CreatedTS { get; set; }
      string ChangedBy { get; set; }
      DateTime ChangedTS { get; set; }
    
    }
  4. Create an interface named IStamper with the following code:
    public interface IStamper { void Insert(IStampedEntity ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required