Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public static ISession GetSession()
  2. {
  3. ISessionFactory holder = ActiveRecordMediator.GetSessionFactoryHolder();
  4. ISessionScope activeScope = holder.ThreadScopeInfo.GetRegisteredScope();
  5. ISession session = null;
  6. var key = holder.GetSessionFactory(typeof(ActiveRecordBase));
  7. if (activeScope == null)
  8. {
  9. session = holder.CreateSession(typeof(ActiveRecordBase));
  10. }
  11. else
  12. {
  13. if (activeScope.IsKeyKnown(key))
  14. session = activeScope.GetSession(key);
  15. else
  16. session = holder.GetSessionFactory(typeof(ActiveRecordBase)).OpenSession();
  17. }
  18.  
  19. return session;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement