/// <summary> /// Dispose /// </summary> /// <param name="iocResolve"></param> public virtual void Dispose(IIocResolve iocResolve) { foreach (var activeTransaction in ActiveTransations.Values) { foreach (var attendedDbContext in activeTransaction.AttendedDbContexts) { iocResolve.Release(attendedDbContext); } activeTransaction.DbContextTransaction.Dispose(); iocResolve.Release(activeTransaction.StartDbContext); } //清除事务 ActiveTransations.Clear(); foreach (var dbContext in DbContexts) { iocResolve.Release(dbContext); } //清除DbContexts DbContexts.Clear(); if (CurrentTransaction == null) { return; } CurrentTransaction.Dispose(); CurrentTransaction = null; }
public virtual void Dispose(IIocResolver iocResolver) { foreach (var dbContext in DbContexts) { iocResolver.Release(dbContext); } DbContexts.Clear(); if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } }