Last Updated: February 25, 2016
·
440
· zote

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.