Example #1
0
        public void OpenSession()
        {
            ISession session = GetNewSession();
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            sessionStorageContainer.Store(session);
        }
Example #2
0
        public ISession GetCurrentSession()
        {
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();
            ISession currentSession = sessionStorageContainer.GetCurrentSession();

            if (currentSession == null)
            {
                currentSession = GetNewSession();
                sessionStorageContainer.Store(currentSession);
            }
            return(currentSession);
        }
Example #3
0
        public void CloseSession()
        {
            ISession session = GetCurrentSession();

            if (session != null && session.IsOpen)
            {
                session.Flush();
                session.Close();
                session.Dispose();
            }
            ISessionStorageContainer sessionStorageContainer = SessionStorageFactory.GetStorageContainer();

            sessionStorageContainer.Store(null);
        }