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

Generating trigger-based auditing

Another approach to auditing involves tracking each change to an entity in a separate audit table. In this recipe, I'll show you how to use NHibernate to generate audit triggers for our entity tables.

Getting ready

Download uNHAddIns.dll from the Unofficial NHibernate AddIns project at http://code.google.com/p/unhaddins/. Save the file to your solution's Lib folder.

How to do it...

  1. Create a new console application project with all standard NHibernate references, the standard NHibernate and log4net configuration, and the Eg.Core model from Chapter 1.
  2. Add a reference to uNHAddIns.dll.
  3. Set the dialect to uNHAddIns.Audit.TriggerGenerator.ExtendedMsSql2008Dialect, uNHAddIns
  4. Add the following code to the Main method of Program.cs ...

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