private void InternalDispose() { PersistenceHelper.RemoveFromStack(this); var session = CurrentSessionContext.Unbind(PersistenceHelper.SessionFactory); if (Transaction != null) { if (!Commits.Contains(false)) { session.Transaction.Commit(); } else { Transaction.Rollback(); } Transaction.Dispose(); } if (session != null) { session.Close(); session.Dispose(); } if (TransactionScope != null) { TransactionScope.Complete(); } }
private void InternalDispose() { PersistenceHelper.RemoveFromStack(this); var session = CurrentSessionContext.Unbind(PersistenceHelper.SessionFactory); if (Transaction != null) { if (!Commits.Contains(false)) { try { session.Transaction.Commit(); } catch (Exception exception) { // write the exception to a log file or mail, but continue context disposal //throw; } } else { Transaction.Rollback(); } Transaction.Dispose(); } if (session != null) { session.Close(); session.Dispose(); } if (TransactionScope != null) { TransactionScope.Complete(); } foreach (var afterCommitAction in AfterCommitActions) { afterCommitAction.Invoke(); } }