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

Setting MS Sql's Context Info

In this recipe, I'll show you how to use Microsoft SQL Server's Context_Info to provide the current username to our audit triggers.

Getting ready

Complete the previous recipe, Generating trigger-based auditing.

Download Ninject.dll and CommonServiceLocator.NinjectAdapter.dll from the Ninject project at http://ninject.org.

Download Microsoft.Practices.ServiceLocation.dll from the Microsoft Patterns and Practices team available at http://commonservicelocator.codeplex.com/.

How to do it...

  1. Add a reference to Ninject.dll, CommonServiceLocator.NinjectAdapter.dll, and Microsoft.Practices.ServiceLocation.dll.
  2. Add the following IAuditColumnSource implementation:
    public class CtxAuditColumnSource : IAuditColumnSource { public IEnumerable<AuditColumn> ...

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