tags:

views:

63

answers:

1

Is someone able to explain NHibernate's CallSessionContext, and contrast it to ThreadStaticSessionContext.

The best explaination I have been able to find, has been from the NHibernate documentation :

  • NHibernate.Context.CallSessionContext- current sessions are tracked by CallContext. You are responsible to bind and unbind an ISession instance with static methods of class CurrentSessionContext.

  • NHibernate.Context.ThreadStaticSessionContext - current session is stored in a thread-static variable. This context only supports one session factory. You are responsible to bind and unbind an ISession instance with static methods of class CurrentSessionContext.

I am familiar with the WebSessionContext, as my usual use of NHibernate is in web applications. This time I am building a WCF service, to be hosted in IIS, and am trying to determine which implementation of ICurrentSessionContext is preferable.

I would like to know the implications of choosing one vs the other, both in this particular case (WCF service), and in general for future reference.

+1  A: 

NHibernate 3 has a WCF-specific implementation, WcfOperationSessionContext

Diego Mijelshon
Thanks Diego. I am currently using NHibernate 2.1, but I downloaded the source for v3 and this looks like what I was hoping for. I think I will add the WcfOperationSessionContext class to our solution.I am going to leave theis question as unanswered for now, as I would still be interested to have the CallSessionContext and ThreadStaticSessionContext explained.
MJ Richardson