Пример #1
0
 protected Task(AstTaskNode astNode)
     : base(astNode)
 {
     DelayValidation = astNode.DelayValidation;
     switch (astNode.IsolationLevel)
     {
         case IsolationLevel.Chaos:
             TaskIsolationLevel = System.Data.IsolationLevel.Chaos;
             break;
         case IsolationLevel.ReadCommitted:
             TaskIsolationLevel = System.Data.IsolationLevel.ReadCommitted;
             break;
         case IsolationLevel.ReadUncommitted:
             TaskIsolationLevel = System.Data.IsolationLevel.ReadUncommitted;
             break;
         case IsolationLevel.RepeatableRead:
             TaskIsolationLevel = System.Data.IsolationLevel.RepeatableRead;
             break;
         case IsolationLevel.Serializable:
             TaskIsolationLevel = System.Data.IsolationLevel.Serializable;
             break;
         case IsolationLevel.Snapshot:
             TaskIsolationLevel = System.Data.IsolationLevel.Snapshot;
             break;
         case IsolationLevel.Unspecified:
             TaskIsolationLevel = System.Data.IsolationLevel.Unspecified;
             break;
         default:
             TaskIsolationLevel = System.Data.IsolationLevel.Serializable;
             break;
     }
 }
Пример #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="EffortTransaction" /> class.
        /// </summary>
        /// <param name="connection">
        ///     The <see cref="EffortTransaction" /> object.
        /// </param>
        /// <param name="isolationLevel">
        ///     The isolation level.
        /// </param>
        /// <exception cref="System.InvalidOperationException">
        ///     Ambient transaction is already set.
        /// </exception>
        public EffortTransaction(
            EffortConnection connection,
            System.Data.IsolationLevel isolationLevel)
        {
            if (System.Transactions.Transaction.Current != null)
            {
                throw new InvalidOperationException("Ambient transaction is already set.");
            }

            this.connection = connection;
            this.isolationLevel = isolationLevel;

            // Initialize new ambient transaction
            System.Transactions.TransactionOptions options =
                new System.Transactions.TransactionOptions();

            options.IsolationLevel = TranslateIsolationLevel(isolationLevel);
            options.Timeout = new TimeSpan(0, 0, connection.ConnectionTimeout);

            this.systemTransaction = new System.Transactions.CommittableTransaction(options);

            this.transaction = NMemory.Transactions.Transaction.Create(this.systemTransaction);
        }
Пример #3
0
        /// <summary>
        /// If self is null, will create a new data access adapter
        /// </summary>
        /// <param name="self"></param>
        /// <param name="level"></param>
        /// <param name="transactionName"></param>
        /// <returns></returns>
        public static DataAccessAdapter CreateTransaction(this DataAccessAdapter self, System.Data.IsolationLevel level, string transactionName)
        {
            if (self == null)
            {
                self = Create();
            }

            self.StartTransaction(level, transactionName);
            return(self);
        }
Пример #4
0
 override public DbTransaction BeginTransaction(System.Data.IsolationLevel iso)
 {
     return(BeginSqlTransaction(iso, null, false));
 }
Пример #5
0
 protected override DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel)
 {
     throw new NotSupportedException();
 }
 /// <param name="isolationLevel">The isolation level.</param>
 public TransactionAttribute(IsolationLevel isolationLevel)
 {
     _isolationLevel = isolationLevel;
 }
Пример #7
0
 protected abstract DbTransaction BeginDbTransaction(IsolationLevel isolationLevel);
 /// <summary>
 ///     Creates a new <see cref="UnitOfWorkAttribute" /> object.
 ///     <see cref="IsTransactional" /> is automatically set to true.
 /// </summary>
 /// <param name="isolationLevel">Transaction isolation level</param>
 public UnitOfWorkAttribute(IsolationLevel isolationLevel)
 {
     IsTransactional = true;
     IsolationLevel = isolationLevel;
 }
Пример #9
0
 protected override System.Data.Common.DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel)
 {
     throw null;
 }
 private static System.Transactions.IsolationLevel MapIsolationLevel(IsolationLevel isolationLevel)
 {
     switch (isolationLevel)
     {
         case IsolationLevel.Unspecified:
             return System.Transactions.IsolationLevel.Unspecified;
         case IsolationLevel.Chaos:
             return System.Transactions.IsolationLevel.Chaos;
         case IsolationLevel.ReadUncommitted:
             return System.Transactions.IsolationLevel.ReadUncommitted;
         case IsolationLevel.ReadCommitted:
             return System.Transactions.IsolationLevel.ReadCommitted;
         case IsolationLevel.RepeatableRead:
             return System.Transactions.IsolationLevel.RepeatableRead;
         case IsolationLevel.Serializable:
             return System.Transactions.IsolationLevel.Serializable;
         case IsolationLevel.Snapshot:
             return System.Transactions.IsolationLevel.Snapshot;
         default:
             throw new ArgumentOutOfRangeException(nameof(isolationLevel), isolationLevel, null);
     }
 }
 /// <summary>
 ///     Begins the transaction.
 /// </summary>
 /// <param name="isolationLevel">Transaction isolation level, see <see cref="System.Data.IsolationLevel" /> for details. </param>
 /// <remarks>
 /// TransactionManager will single TransactionScope, subsequent call to <see cref="BeginTransaction"/> will return same scope
 /// until <see cref="CommitTransaction"/> or <see cref="RollbackTransaction"/> is called.
 /// </remarks>
 /// <returns>The transaction instance.</returns>
 public IDisposable BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
 {
     return this.transaction ??
         (this.transaction = new TransactionScope(TransactionScopeOption.Required,
             new TransactionOptions {IsolationLevel = MapIsolationLevel(isolationLevel)}));
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="level"></param>
        public virtual void BeginTransaction(string name, IsolationLevel? level)
        {
            if (name == null || name.Trim().Equals(string.Empty))
                throw new BusinessLayerException("The transaction name cannot be null or empty", "BeginTransaction");

            if (this.Exists(name))
                throw new BusinessLayerException(string.Format("The transaction name ({0}) to add is used by another one..", name), "BeginTransaction");

            int index = transactions.Count;

            if (this.transactions.Count == 0)
            {
                //if (!sessionProvider.HasSessionBinded)
                //    throw new BusinessLayerException("Error on beginning a new transaction because of missing binded document session.", "BeginTransaction");

                this.transactionScope = new TransactionScope();
            }
            this.transactions.Push(new TransactionInfo(name, index));
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="level"></param>
 public virtual void BeginTransaction(IsolationLevel? level)
 {
     int index = transactions.Count;
     this.BeginTransaction(string.Format("{0}_{1}", DefaultNaming, index));
 }
Пример #14
0
        /// <summary>
        /// Begins a database transaction
        /// </summary>
        /// <param name="isolationLevel">The isolation level of the transaction</param>
        /// <returns>An object representing the new transaction</returns>
        protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
        {
            if (CurrentTransaction != null)
            {
                throw new InvalidOperationException(Strings.EntityClient_TransactionAlreadyStarted);
            }

            if (_storeConnection == null)
            {
                throw new InvalidOperationException(Strings.EntityClient_ConnectionStringNeededBeforeOperation);
            }

            if (State != ConnectionState.Open)
            {
                throw new InvalidOperationException(Strings.EntityClient_ConnectionNotOpen);
            }

            DbTransaction storeTransaction = null;
            try
            {
                storeTransaction = _storeConnection.BeginTransaction(isolationLevel);
            }
            catch (Exception e)
            {
                if (e.IsCatchableExceptionType())
                {
                    throw new EntityException(Strings.EntityClient_ErrorInBeginningTransaction, e);
                }
                throw;
            }

            // The provider is problematic if it succeeded in beginning a transaction but returned a null
            // for the transaction object
            if (storeTransaction == null)
            {
                throw new ProviderIncompatibleException(
                    Strings.EntityClient_ReturnedNullOnProviderMethod("BeginTransaction", _storeConnection.GetType().Name));
            }

            _currentTransaction = new EntityTransaction(this, storeTransaction);
            return _currentTransaction;
        }
Пример #15
0
 protected abstract DbTransaction BeginDbTransaction(IsolationLevel isolationLevel);
Пример #16
0
        public NHibernateSagaRepository(ISessionFactory sessionFactory)
        {
            _sessionFactory = sessionFactory;

            _insertIsolationLevel = System.Data.IsolationLevel.ReadCommitted;
        }
Пример #17
0
 protected abstract System.Data.Common.DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel);
Пример #18
0
 /// <summary>
 /// Starts a transaction. The resulting transaction handle can be used to chain operations together.
 /// </summary>
 /// <param name="isolationLevel">Isolation level of the operations executed in the transaction.</param>
 /// <returns></returns>
 public abstract ITransaction BeginTransaction(System.Data.IsolationLevel isolationLevel);
Пример #19
0
 public System.Data.Common.DbTransaction BeginTransaction(System.Data.IsolationLevel isolationLevel)
 {
     return(default(System.Data.Common.DbTransaction));
 }
Пример #20
0
 public static HsqlIsolationLevel ToHsqlIsolationLevel(IsolationLevel isolationLevel)
 {
     switch (isolationLevel)
     {
         case IsolationLevel.ReadCommitted:
         case IsolationLevel.Unspecified:
             {
                 return HsqlIsolationLevel.ReadCommited;
             }
         case IsolationLevel.ReadUncommitted:
             {
                 return HsqlIsolationLevel.ReadUncommited;
             }
         case IsolationLevel.RepeatableRead:
             {
                 return HsqlIsolationLevel.RepeatableRead;
             }
         case IsolationLevel.Serializable:
             {
                 return HsqlIsolationLevel.Serializable;
             }
         case IsolationLevel.Chaos:
         case IsolationLevel.Snapshot:
         default:
             {
                 throw new ArgumentException(string.Format(
                     "Unsupported Level: {0}",
                     isolationLevel),
                     "isolationLevel");
             }
     }
 }
Пример #21
0
 public IDocumentSession DirtyTrackedSession(string tenantId, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
 {
     return(OpenSession(tenantId, DocumentTracking.DirtyTracking, isolationLevel));
 }
Пример #22
0
 /// <summary>Begins a transaction with the specified isolation level by using the underlying provider. </summary>
 /// <returns>
 /// A new <see cref="T:System.Data.Entity.Core.EntityClient.EntityTransaction" />. The returned
 /// <see
 ///     cref="T:System.Data.Entity.Core.EntityClient.EntityTransaction" />
 /// instance can later be associated with the
 /// <see
 ///     cref="T:System.Data.Entity.Core.EntityClient.EntityCommand" />
 /// to execute the command under that transaction.
 /// </returns>
 /// <param name="isolationLevel">The isolation level of the transaction.</param>
 /// <exception cref="T:System.InvalidOperationException">
 /// The underlying provider is not known.-or-The call to
 /// <see
 ///     cref="M:System.Data.Entity.Core.EntityClient.EntityConnection.BeginTransaction" />
 /// was made on an
 /// <see
 ///     cref="T:System.Data.Entity.Core.EntityClient.EntityConnection" />
 /// that already has a current transaction.-or-The state of the
 /// <see
 ///     cref="T:System.Data.Entity.Core.EntityClient.EntityConnection" />
 /// is not
 /// <see
 ///     cref="F:System.Data.ConnectionState.Open" />
 /// .
 /// </exception>
 public new virtual EntityTransaction BeginTransaction(IsolationLevel isolationLevel)
 {
     return base.BeginTransaction(isolationLevel) as EntityTransaction;
 }
Пример #23
0
 public IDocumentSession LightweightSession(string tenantId, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
 {
     return(OpenSession(tenantId, DocumentTracking.None, isolationLevel));
 }
Пример #24
0
 /// <summary>
 /// 开启事物
 /// </summary>
 /// <returns></returns>
 public async Task BeginTransactionAsync(System.Data.IsolationLevel isolationLevel)
 {
     await BaseDB.BaseDataContext.Database.BeginTransactionAsync(isolationLevel);
 }
Пример #25
0
 public System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel il)
 {
 }
 public TransactionScopeAdapter(System.Data.IsolationLevel level = System.Data.IsolationLevel.Serializable)
 {
     tran = new TransactionScope();
 }
Пример #27
0
 public TransactionForK3Attribute(System.Data.IsolationLevel isolationLevel = System.Data.IsolationLevel.ReadCommitted)
 {
     _isolationLevel = isolationLevel;
 }
Пример #28
0
 abstract internal void ExecuteTransaction(TransactionRequest transactionRequest, string name, System.Data.IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest);
Пример #29
0
 public IBM.Data.DB2.DB2Transaction BeginTransaction(System.Data.IsolationLevel isolationL)
 {
     throw null;
 }
Пример #30
0
 IDbTransaction IDbConnection.BeginTransaction(IsolationLevel il)
 {
     return(this.BeginTransaction(il));
 }
Пример #31
0
 System.Data.IDbTransaction System.Data.IDbConnection.BeginTransaction(System.Data.IsolationLevel isolationL)
 {
     throw null;
 }
Пример #32
0
 public DbTransaction BeginTransaction(IsolationLevel isolationLevel)
 {
     return(this.BeginDbTransaction(isolationLevel));
 }
Пример #33
0
        ///////////////////////////////////////////////////////////////////////////

        #region Private Methods
        private System.Data.IsolationLevel GetSystemDataIsolationLevel(
            SQLiteConnection connection,
            Transaction transaction,
            System.Data.IsolationLevel defaultIsolationLevel,
            bool throwOnUnavailable,
            bool throwOnUnsupported
            )
        {
            if (transaction == null)
            {
                //
                // NOTE: If neither the transaction nor connection isolation
                //       level is available, throw an exception if instructed
                //       by the caller.
                //
                if (connection != null)
                {
                    return(connection.GetDefaultIsolationLevel());
                }

                if (throwOnUnavailable)
                {
                    throw new InvalidOperationException(
                              "isolation level is unavailable");
                }

                return(defaultIsolationLevel);
            }

            System.Transactions.IsolationLevel isolationLevel =
                transaction.IsolationLevel;

            //
            // TODO: Are these isolation level mappings actually correct?
            //
            switch (isolationLevel)
            {
            case IsolationLevel.Unspecified:
                return(System.Data.IsolationLevel.Unspecified);

            case IsolationLevel.Chaos:
                return(System.Data.IsolationLevel.Chaos);

            case IsolationLevel.ReadUncommitted:
                return(System.Data.IsolationLevel.ReadUncommitted);

            case IsolationLevel.ReadCommitted:
                return(System.Data.IsolationLevel.ReadCommitted);

            case IsolationLevel.RepeatableRead:
                return(System.Data.IsolationLevel.RepeatableRead);

            case IsolationLevel.Serializable:
                return(System.Data.IsolationLevel.Serializable);

            case IsolationLevel.Snapshot:
                return(System.Data.IsolationLevel.Snapshot);
            }

            //
            // NOTE: When in "strict" mode, throw an exception if the isolation
            //       level is not recognized; otherwise, fallback to the default
            //       isolation level specified by the caller.
            //
            if (throwOnUnsupported)
            {
                throw new InvalidOperationException(
                          String.Format(CultureInfo.InvariantCulture,
                                        "unsupported isolation level {0}", isolationLevel));
            }

            return(defaultIsolationLevel);
        }
Пример #34
0
        public NHibernateSagaRepository(ISessionFactory sessionFactory, System.Data.IsolationLevel isolationLevel)
        {
            _sessionFactory = sessionFactory;

            _insertIsolationLevel = isolationLevel;
        }
Пример #35
0
 public ITransaction BeginTransaction(System.Data.IsolationLevel isolationLevel)
 {
     return(_actualImplementation.BeginTransaction(isolationLevel));
 }
Пример #36
0
 public new System.Data.Odbc.OdbcTransaction BeginTransaction(System.Data.IsolationLevel isolevel)
 {
     throw null;
 }
 public EntityFrameworkUnitOfWork(DbContext dbContext, IsolationLevel isolationLevel)
 {
     _dbContext   = dbContext;
     _transaction = dbContext.Database.BeginTransaction(isolationLevel);
 }
 public DataMappingTransaction(IDataAccessFactory accessFactory, System.Data.IsolationLevel isolationLevel)
 {
     this._accessFactory = accessFactory;
     this._accessFactory.BeginTransaction(isolationLevel);
 }
Пример #39
0
 public DbContextTransaction BeginTrans(System.Data.IsolationLevel isolationLevel = System.Data.IsolationLevel.ReadCommitted)
 {
     return(base.Database.BeginTransaction(isolationLevel));
 }
 /// <summary>
 ///     Creates a new <see cref="UnitOfWorkAttribute" /> object.
 ///     <see cref="IsTransactional" /> is automatically set to true.
 /// </summary>
 /// <param name="isolationLevel">Transaction isolation level</param>
 /// <param name="timeout">Transaction  timeout as milliseconds</param>
 public UnitOfWorkAttribute(IsolationLevel isolationLevel, int timeout)
 {
     IsTransactional = true;
     IsolationLevel = isolationLevel;
     Timeout = TimeSpan.FromMilliseconds(timeout);
 }
Пример #41
0
 public void Begin(System.Data.IsolationLevel isolatedLevel)
 {
     //throw new NotImplementedException();
 }
Пример #42
0
 IDbTransaction IDbConnection.BeginTransaction(IsolationLevel il)
 {
     return this.BeginTransaction(il);
 }
Пример #43
0
 public DbContextTransaction BeginTransaction(System.Data.IsolationLevel isolation) => Database.BeginTransaction(isolation);
Пример #44
0
 public DbTransaction BeginTransaction(IsolationLevel isolationLevel)
 {
     return this.BeginDbTransaction(isolationLevel);
 }
Пример #45
0
 /// <summary>
 /// 开启事物
 /// </summary>
 /// <returns></returns>
 public void BeginTransaction(System.Data.IsolationLevel isolationLevel)
 {
     BaseDB.BaseDataContext.Database.BeginTransaction();
 }
Пример #46
0
        /// <summary>
        /// Begins a database transaction
        /// </summary>
        /// <param name="isolationLevel"> The isolation level of the transaction </param>
        /// <returns> An object representing the new transaction </returns>
        protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
        {
            if (_fakeConnectionState != null)
            {
                return new EntityTransaction();
            }

            if (CurrentTransaction != null)
            {
                throw new InvalidOperationException(Strings.EntityClient_TransactionAlreadyStarted);
            }

            if (_storeConnection == null)
            {
                throw Error.EntityClient_ConnectionStringNeededBeforeOperation();
            }

            if (State != ConnectionState.Open)
            {
                throw Error.EntityClient_ConnectionNotOpen();
            }

            var interceptionContext = new BeginTransactionInterceptionContext(InterceptionContext);
            if (isolationLevel != IsolationLevel.Unspecified)
            {
                interceptionContext = interceptionContext.WithIsolationLevel(isolationLevel);
            }

            DbTransaction storeTransaction = null;
            try
            {
                var executionStrategy = DbProviderServices.GetExecutionStrategy(_storeConnection, GetMetadataWorkspace());
                storeTransaction = executionStrategy.Execute(
                    () =>
                    {
                        if (DbInterception.Dispatch.Connection.GetState(_storeConnection, InterceptionContext) == ConnectionState.Broken)
                        {
                            DbInterception.Dispatch.Connection.Close(_storeConnection, interceptionContext);
                        }

                        if (DbInterception.Dispatch.Connection.GetState(_storeConnection, InterceptionContext) == ConnectionState.Closed)
                        {
                            DbInterception.Dispatch.Connection.Open(_storeConnection, interceptionContext);
                        }

                        return DbInterception.Dispatch.Connection.BeginTransaction(
                            _storeConnection,
                            interceptionContext);
                    });
            }
            catch (Exception e)
            {
                if (e.IsCatchableExceptionType())
                {
                    throw new EntityException(Strings.EntityClient_ErrorInBeginningTransaction, e);
                }
                throw;
            }

            // The provider is problematic if it succeeded in beginning a transaction but returned a null
            // for the transaction object
            if (storeTransaction == null)
            {
                throw new ProviderIncompatibleException(
                    Strings.EntityClient_ReturnedNullOnProviderMethod("BeginTransaction", _storeConnection.GetType().Name));
            }

            _currentTransaction = new EntityTransaction(this, storeTransaction);
            return _currentTransaction;
        }
 /// <param name="transactionPropagation">The transaction propagation.</param>
 /// <param name="isolationLevel">The isolation level.</param>
 public TransactionAttribute(TransactionPropagation transactionPropagation,
                             IsolationLevel isolationLevel) : this(transactionPropagation)
 {
     _isolationLevel = isolationLevel;
 }