There's also this that I've written up and made the code available for. Links to code and samples are in the blog post. Have used this on a number of projects and had no issues with it to this point.
http://igloocoder.com/archive/2009/05/01/a-little-more-wcf-nhibernate.aspx Donald From: [email protected] [mailto:[email protected]] On Behalf Of Fabio Maulo Sent: November-12-09 1:43 PM To: [email protected] Subject: [nhusers] Re: Nhibernate, WCF and SessionContext http://fabiomaulo.blogspot.com/2009/10/nhibernate-wcf-session-per-call-in.ht ml 2009/11/12 Andyk <[email protected]> Hi, can anyone tell me which sessioncontext should be used in a Wcf environment. Currently I have a web application calling a WCF service, hosted in IIS. The WCF service does all the work and uses NHibernate. I am using sessioncontext in a static class to manage nhibernate session like this: public static ISession GetCurrentSession() { if (!CurrentSessionContext.HasBind(SessionFactory)) { CurrentSessionContext.Bind(SessionFactory.OpenSession ()); } return SessionFactory.GetCurrentSession(); } and in the config I have: <property name="current_session_context_class">call</property> When multiple users access the system, exceptions start being thrown, such as "Session is closed". Which gives me the impression the session is being shared, and isnt unique to each request. Currently, for each WCF function, Im calling: NhibernateHelper.BeginTransaction(); // Do work NHibernateHelper.CommitTransaction(); NHibernateHelper.DisposeSession(); There's something Im doing wrong, but Im racking my brains trying to find the solution. Any response gratefully appreciated. Andy -- Fabio Maulo No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.425 / Virus Database: 270.14.61/2498 - Release Date: 11/12/09 07:38:00 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
