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

Using dependency injection with entities

In this recipe, I'll show you how we can inject services into our entities to separate implementation details from our real business logic.

Getting ready

Download uNHAddIns.CommonServiceLocatorAdapters.dll from the Unofficial NHibernate AddIns project at http://code.google.com/p/unhaddins/.

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/.

Put these three assemblies in your solution's Lib folder.

How to do it...

  1. Create a new console application project named IoCByteCode.
  2. Add a reference to NHibernate.dll ...

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