Exemplo n.º 1
0
        public void Dispose()
        {
            if (!_isBeginCalled || IsDisposed)
            {
                return;
            }

            IsDisposed = true;

            if (!_isSucceed)
            {
                OnFailed(_exception);
            }

            if (Options.IsTransactional)
            {
                _transactionStrategy.Dispose();
            }
            else
            {
                foreach (var dbContext in GetAllActiveDbContexts())
                {
                    dbContext.Dispose();
                    _dependencyResolver.Release(dbContext);
                }
            }

            _activeDbContexts.Clear();

            OnDisposed();
        }
Exemplo n.º 2
0
 public void Dispose()
 {
     try
     {
         transactionStrategy.Dispose();
     }
     finally
     {
         if (sharedConnection != null)
         {
             sharedConnection.DoClose();
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Tells the connection manager is starting
        /// </summary>
        public IDisposable OperationStarting(IUpgradeLog upgradeLog, List <SqlScript> executedScripts, TransactionMode transactionMode)
        {
            upgradeConnection = CreateConnection(upgradeLog);
            if (upgradeConnection.State == ConnectionState.Closed)
            {
                upgradeConnection.Open();
            }


            transactionStrategy = transactionStrategyFactory[transactionMode]();
            transactionStrategy.Initialise(upgradeConnection, upgradeLog);

            return(new DelegateDisposable(() =>
            {
                transactionStrategy.Dispose();
                upgradeConnection.Dispose();
                transactionStrategy = null;
                upgradeConnection = null;
            }));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Tells the connection manager is starting
        /// </summary>
        public IDisposable OperationStarting(IUpgradeLog upgradeLog, List <SqlScript> executedScripts)
        {
            upgradeConnection = CreateConnection(upgradeLog);
            if (upgradeConnection.State == ConnectionState.Closed)
            {
                upgradeConnection.Open();
            }
            if (transactionStrategy != null)
            {
                throw new InvalidOperationException("OperationStarting is meant to be called by DbUp and can only be called once");
            }
            transactionStrategy = transactionStrategyFactory[TransactionMode]();
            transactionStrategy.Initialise(upgradeConnection, upgradeLog, executedScripts);

            return(new DelegateDisposable(() =>
            {
                transactionStrategy.Dispose();
                upgradeConnection.Dispose();
                transactionStrategy = null;
                upgradeConnection = null;
            }));
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     transactionStrategy.Dispose();
 }