public override void Dispose(IIocResolver iocResolver) { //foreach (var dtx in DbContexts) //{ // var CurrentTransaction = dataBaseTransactions.FirstOrDefault(t => t.dbContext == dtx); // if (CurrentTransaction != null && !CurrentTransaction.isCommit && CurrentTransaction.Transaction != null) // { // CurrentTransaction.Transaction.Rollback(); // CurrentTransaction.Transaction.Dispose(); // dataBaseTransactions.Remove(CurrentTransaction); // } //} foreach (var activeTransaction in ActiveTransactions.Values) { activeTransaction.DbContextTransaction.Dispose(); foreach (var attendedDbContext in activeTransaction.AttendedDbContexts) { iocResolver.Release(attendedDbContext); } iocResolver.Release(activeTransaction.StarterDbContext); } ActiveTransactions.Clear(); base.Dispose(iocResolver); }
public virtual void Dispose() { foreach (var activeTransaction in ActiveTransactions.Values) { //if (activeTransaction.AttendedDbContexts != null && activeTransaction.AttendedDbContexts.Count > 0) //{ // foreach (var attendedDbContext in activeTransaction.AttendedDbContexts) // { // attendedDbContext.Dispose(); // } //} if (activeTransaction.DbContextTransaction != null) { activeTransaction.DbContextTransaction.Dispose(); } if (activeTransaction.DbContext.Database.CurrentTransaction != null) { activeTransaction.DbContext.Database.CurrentTransaction.Dispose(); } } ActiveTransactions.Clear(); if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } }
/// <summary> /// Rollbacks transaction and closes database connection. /// </summary> protected override void DisposeUow() { foreach (ActiveTransactionInfo activeTransaction in ActiveTransactions.Values) { foreach (ISession session in activeTransaction.AttendedSessions) { session.Dispose(); } activeTransaction.Transaction.Dispose(); activeTransaction.StarterSession.Dispose(); } foreach (ISession activeSession in ActiveSessions.Values) { activeSession.Dispose(); } ActiveSessions.Clear(); ActiveTransactions.Clear(); }