Stop injecting ISession
Stop injection ISession and start to inject ISessionFactory. Some times you'll need to open stateless session and now you can.
Any in my company, we implemented an SessionManager that hold all session open logic. We have just 3 methods on it:
- GetSession() => that returns current opened session from context or start a new one.
- GetExclusiveSession() => that always returns a new session, and should be used on using block. We need this because in an application sometimes we need 2 transactions in same request.
- GetStatelessSession() => same that GetSession() but stateless.
Written by José H. K Silva
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nhibernate
Authors
Related Tags
#nhibernate
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#