Ejemplo n.º 1
0
        private void ReleaseCurrentTransaction()
        {
            if (_transaction != null)
            {
                _transaction.TransactionCommitted  -= TransactionCommitted;
                _transaction.TransactionRolledback -= TransactionRolledback;
                _transaction.Dispose();
            }
            _transaction = null;

            if (_entityFrameworkContext.Connection.State == ConnectionState.Open)
            {
                _entityFrameworkContext.Connection.Close();
            }
        }
Ejemplo n.º 2
0
        public ITransaction BeginTransaction(IsolationLevel isolationLevel)
        {
            if (_transaction != null)
            {
                throw new InvalidOperationException("Cannot start transaction.");
            }

            if (_entityFrameworkContext.Connection.State != ConnectionState.Open)
            {
                _entityFrameworkContext.Connection.Open();
            }

            IDbTransaction transaction = _entityFrameworkContext.Connection.BeginTransaction(isolationLevel);

            _transaction = new EFTransaction(transaction);
            _transaction.TransactionCommitted  += TransactionCommitted;
            _transaction.TransactionRolledback += TransactionRolledback;
            return(_transaction);
        }
Ejemplo n.º 3
0
        private void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }
            if (_disposed)
            {
                return;
            }

            if (_transaction != null)
            {
                _transaction.Dispose();
                _transaction = null;
            }
            if (_entityFrameworkContext != null)
            {
                _entityFrameworkContext.Dispose();
                _entityFrameworkContext = null;
            }
            _disposed = true;
        }