tags:

views:

203

answers:

1

I am looking for the best way to configure Microsoft.Practices.Unity.IUnityContainer to manage the lifetime of an nHibernate ISessionFactory for an asp.net application. I would also like unity to inject my IDataLayer implementation which takes an instance of NHibernate.ISession by calling GetCurrentSession on its managed ISessionFactory.

Please include code in your answer :-)

A: 

You can also use a direct dependency to ISession and use some NHConversationLifetimeManager. Or look at Spring's ISession management (the Java one for instance). I think they already worked on this subject (ie Hibernate ISession & Dependency Injection).

Sorry, no code!

Nelson