WCF + NHibernate + ISession =?

I start at both WCF and NHibernate. However, I need to make a small project that includes several services (made with WCF) and a constant level (made with NHibernate).

My problem is using ISession and ISessionFactory. I read (and saw) that creating an ISessionFactory is very difficult (and thread safe). So, I think that I could only instantiate this class once at runtime. I'm right?

My problem is more about the ISession class. I don’t know exactly with what granularity I should use it. I think I should use / create one instance for each service call (I use "services for every call"). Again, am I right?

+6
nhibernate wcf
source share
1 answer

Are you there. A factory session is expensive to build and fits well as a singleton, while a session is a lighter contextual object wrapping a β€œunit of work”.

To learn more, you can read about WCF Castle, which offers a solution to this problem. Here 's a blog post that explores it.

+5
source share

All Articles