NHibernate Facility
The NHibernate Facility enables the usage of NHibernate O/R framework for your components.
| Facility Summary | |||||||||||
|
| ||||||||||
Introduction
The NHibernate facility provides two levels of integration with NHibernate. You should pick the one you feel more comfortable with.
- You can just receive the ISessionFactory and Configuration on your components and use it as you wish.
- You can use ISessionManager component to manage sessions.
Integration level 1
This example illustrates how you can have fine grained control over ISessionFactory and, thus, ISession.
using NHibernate; using NHibernate.Cfg; public class MyDataAccessClass { private ISessionFactory _sessFactory; private Configuration _cfg; public MyDataAccessClass(ISessionFactory sessFactory, Configuration cfg) { _sessFactory = sessFactory; _cfg = cfg; } public void SaveSomething(object item) { ISession session = _sessFactory.OpenSession(); // .. do whatever you want session.Close(); } }
With this scenario you have to control transactions and share sessions instances manually.
Integration level 2
The second level of integration introduce the ISessionManager interface so you can use session and leave to the ISessionManager implementation the responsability of sharing compatible session within an invocation chain and be aware of transactions.
Site Map
Please consult the others documents to learn more about the NHibernate facility.
Required Assemblies
- Castle.Facilities.NHibernateIntegration.dll
- NHibernate assemblies