I think the solution of uNhAddIns <http://code.google.com/p/unhaddins/>creating a new WCF Behavior is a good option.
http://fabiomaulo.blogspot.com/2009/10/nhibernate-wcf-session-per-call-in.html I think is not very easy to understand, start to search how to implement a WCF Behavior. See how to use ThreadStaticSessionContext with Nhibernate. See the implementation of uNhAddIns http://code.google.com/p/unhaddins/source/browse/#hg%2FuNhAddIns%2FuNhAddIns.WCF After you created a new WCF behavior you could write some code like the example below: [NhSessionPerCall()] [EnableClientAccess] public class MyEntityService { ISessionFactory _sfp; MyEntityService() { //find your sessionFactory , for instance using DI container _sfp= ServiceLocator.Current.GetInstance<ISessionFactory>(); } IQueryable<MyEntity> FindBla(...params...) { //now you do not need to open or close sessions , WCF behavior will make this job for you. _session = _sfp.GetCurrentSession(); return session.Query<MyEntity>().Where(...).....; } } This is just a pointer for the solution that I think is good option for RIA services and NHibernate. Maybe you could find complete sample somewhere. Microsoft has an example of Nhibernate and RIA Services, http://archive.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=4316 but someone at altnethispano making a Webcast how to manage Nhibernate sessions consider this example as an Anti-Pattern. Maybe you could not expect good examples of Nhibernate from Microsoft employees. -- 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.
