public void StartSession() { //The session factory provides the session ISession session = SessionFactory.OpenSession(); //In this context, we will use on transaction per //web request session.BeginTransaction(); var cache = new SessionCache(); cache.CacheSession(session); }
public void EndSession() { var cache = new SessionCache(); ISession session = cache.GetSession(); //Commit the transaction if it has not been //rolled back. ITransaction transaction = session.Transaction; if (transaction.IsActive) { transaction.Commit(); } session.Dispose(); }