I am starting to create an application, and I plan to use ServiceStack. I just want to know what are the best methods / good approaches for handling NHibernate ISession or other contextual session request objects.
I was thinking of registering ISessionFactory in Ioc like:
container.Register<ISessionFactory>(sessionFactory);
And if necessary, get a new Session object ... Or you can directly provide a session object:
container.Register<ISession>(c => sessionFactory.OpenSession()).ReusedWithin(ReuseScope.None);
Or either handle ISession and the default transaction through the Global.asax BeginRequest event:
protected void Application_BeginRequest(object sender, EventArgs e) { var session = factory.OpenSession(); ITransaction itrans = session.BeginTransaction(); Context.Items.Add("session", session); Context.Items.Add("trans", itrans); }
So, I lost, what are the best practices given the above technologies or the like, for example, EF or other Rest-Services infrastructure?
Thanks in advance
servicestack nhibernate
RMalke
source share