Using dependency injection with entities
In this recipe, we will show you how you can inject services into your entities to separate implementation details from your real business logic.
Getting ready
- Download
uNHAddIns.CommonServiceLocatorAdapters.dll
from the unofficial NHibernate AddIns project at https://bitbucket.org/fabiomaulo/unhaddins - Download
Ninject.dll
andCommonServiceLocator.NinjectAdapter.dll
from the Ninject project at http://ninject.org - Download
Microsoft.Practices.ServiceLocation.dll
from the Microsoft patterns and practices team and available at http://commonservicelocator.codeplex.com/ - Put these three assemblies in your solution's
Lib
folder
How to do it…
- Create a new console application project named
IoCByteCode
. - Add a reference to ...
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.