コード例 #1
0
ファイル: Task.cs プロジェクト: japj/vulcan
 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
ファイル: Adapter.cs プロジェクト: Aya111/Aqarpress
        /// <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);
コード例 #8
0
 /// <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
ファイル: System.Data.Odbc.cs プロジェクト: omajid/corefx
 protected override System.Data.Common.DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel)
 {
     throw null;
 }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
 /// <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)}));
 }
コード例 #12
0
        /// <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));
        }
コード例 #13
0
 /// <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
ファイル: StoreBase.cs プロジェクト: joephayes/trinity-rdf
 /// <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)
 {
 }
コード例 #26
0
 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
ファイル: System.Data.Odbc.cs プロジェクト: omajid/corefx
 public new System.Data.Odbc.OdbcTransaction BeginTransaction(System.Data.IsolationLevel isolevel)
 {
     throw null;
 }
コード例 #37
0
 public EntityFrameworkUnitOfWork(DbContext dbContext, IsolationLevel isolationLevel)
 {
     _dbContext   = dbContext;
     _transaction = dbContext.Database.BeginTransaction(isolationLevel);
 }
コード例 #38
0
 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));
 }
コード例 #40
0
 /// <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
ファイル: DatabaseInit.cs プロジェクト: malweka/GoliathData
 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;
 }