Search code examples
wcfnhibernatenhibernate-3

NHibernate + WCF + Windows Service and WcfOperationSessionContext class


  • I have a Windows Service Application in which i create WCF services in it.
  • One of the services is data services: add, delete, read , updatte data via WCF.
  • WCF use NHibernate for data manipulation

So my guestions are:

  • Any advice (best practice) for session management for Hibernate using with WCF?

  • Anybody knows anything about

WcfOperationSessionContext (hibernate 3.0) class?

how to use it with WCF?

Well to make it concrete :

Suppose that i have WCF Service called DataServices

class WCFDataService .....
{

   void SaveMyEntity(MyEntity entity)
    {



         .....................?? // How to do? Best Way

         // Should i take one session  and use it all times
         // Should i take session and dipsose when operation finished then get 
         //new session for new operations?
         // If many clients call my WCF service function at the same time?
         // what may go wrong?
         // etc....


     }


 }

And I need a NHibernateServiceProvider class

class NHibernateServiceProvider ....
{

    // How to get Session ?? Best way

     ISession GetCurrentSession(){.... }
     DisposeSession(){ ....}
}

Best Wishes

PS: I have read similiar entries here and other web pages. But can not see "concrete" answers.


Solution

  • Here is a post describing, in detail, all the steps for registering and using the WcfOperationSessionContext. It also includes instructions for using it with the agatha-rrsl project.