Generating trigger-based auditing
Another approach to auditing involves tracking each change to an entity in a separate audit table. In this recipe, we will show you how to use NHibernate to generate audit triggers for your entity tables.
Getting ready
Download uNHAddIns.dll
from the unofficial NHibernate AddIns project at https://bitbucket.org/fabiomaulo/unhaddins. Save the file to your solution's Lib
folder.
How to do it…
- 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, The Configuration and Schema. - Add a reference to
uNHAddIns.dll
. - Set the
dialect
touNHAddIns.Audit.TriggerGenerator.ExtendedMsSql2008Dialect, uNHAddIns
. - Add the ...
Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.