0

I am writing a wcf service and i wanna use NHibernate for the data access objects. My doubt is about how would be the best approach to handle the nh's sessions.

I've been reading about the topic and seems like per call is the best way, also i found the uNhAddIns implementation, but does anyone know if this is a better choice?

any advice will be appreciated.

elvin
  • 961
  • 1
  • 9
  • 26
  • Is it a standalone wcf library service or a part of web solution? – IamDeveloper Jul 14 '11 at 07:54
  • What fits best in the architecture you are using, and what sort of data are you handling? It is not that the is one solution that fits all and is better then all other solutions. – Peter Jul 14 '11 at 07:55

1 Answers1

0

Have one NHibernateSessionFactory class such that we always get a single instance of the NHibernate session factory and start using them in wcf service on need basis. You can have a instance of this in the class implementing the operation contracts

private readonly NHibernateSessionFactory m_sessionfactory = new NHibernateSessionFactory();

you can start using it on need basis with in the class:

using (ISession session = m_sessionfactory.Instance().OpenSession())
{
//----------Do something here
}

I am not sure whether you are looking for these type of details or not. If not please ingnore my response.

Kishore Borra
  • 269
  • 3
  • 15