/// <summary> /// Finalizes the request. If current session exists the method flushes it and /// closes. Call this method at the end of ASP.NET request. /// </summary> public static void EndRequest() { if (HasCurrent()) { Close(); } SessionSource.Set(null); }
/// <summary> /// Flushes and closes current session. /// </summary> public static void CloseAndFlush() { ISession session = SessionSource.Get(); if (session != null) { session.Flush(); session.Close(); SessionSource.Set(null); } }
/// <summary> /// Closes current session. /// </summary> /// <remarks><b>N.B.</b> Close do not flush the session.</remarks> public static void Close() { ISession session = SessionSource.Get(); if (session != null) { session.Close(); session.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); SessionSource.Set(null); } }