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; } }
/// <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); }
/// <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); }
override public DbTransaction BeginTransaction(System.Data.IsolationLevel iso) { return(BeginSqlTransaction(iso, null, false)); }
protected override DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel) { throw new NotSupportedException(); }
/// <param name="isolationLevel">The isolation level.</param> public TransactionAttribute(IsolationLevel isolationLevel) { _isolationLevel = isolationLevel; }
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; }
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)); }
/// <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; }
protected abstract DbTransaction BeginDbTransaction(IsolationLevel isolationLevel);
public NHibernateSagaRepository(ISessionFactory sessionFactory) { _sessionFactory = sessionFactory; _insertIsolationLevel = System.Data.IsolationLevel.ReadCommitted; }
protected abstract System.Data.Common.DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel);
/// <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);
public System.Data.Common.DbTransaction BeginTransaction(System.Data.IsolationLevel isolationLevel) { return(default(System.Data.Common.DbTransaction)); }
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"); } } }
public IDocumentSession DirtyTrackedSession(string tenantId, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted) { return(OpenSession(tenantId, DocumentTracking.DirtyTracking, isolationLevel)); }
/// <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; }
public IDocumentSession LightweightSession(string tenantId, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted) { return(OpenSession(tenantId, DocumentTracking.None, isolationLevel)); }
/// <summary> /// 开启事物 /// </summary> /// <returns></returns> public async Task BeginTransactionAsync(System.Data.IsolationLevel isolationLevel) { await BaseDB.BaseDataContext.Database.BeginTransactionAsync(isolationLevel); }
public System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel il) { }
public TransactionScopeAdapter(System.Data.IsolationLevel level = System.Data.IsolationLevel.Serializable) { tran = new TransactionScope(); }
public TransactionForK3Attribute(System.Data.IsolationLevel isolationLevel = System.Data.IsolationLevel.ReadCommitted) { _isolationLevel = isolationLevel; }
abstract internal void ExecuteTransaction(TransactionRequest transactionRequest, string name, System.Data.IsolationLevel iso, SqlInternalTransaction internalTransaction, bool isDelegateControlRequest);
public IBM.Data.DB2.DB2Transaction BeginTransaction(System.Data.IsolationLevel isolationL) { throw null; }
IDbTransaction IDbConnection.BeginTransaction(IsolationLevel il) { return(this.BeginTransaction(il)); }
System.Data.IDbTransaction System.Data.IDbConnection.BeginTransaction(System.Data.IsolationLevel isolationL) { throw null; }
public DbTransaction BeginTransaction(IsolationLevel isolationLevel) { return(this.BeginDbTransaction(isolationLevel)); }
/////////////////////////////////////////////////////////////////////////// #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); }
public NHibernateSagaRepository(ISessionFactory sessionFactory, System.Data.IsolationLevel isolationLevel) { _sessionFactory = sessionFactory; _insertIsolationLevel = isolationLevel; }
public ITransaction BeginTransaction(System.Data.IsolationLevel isolationLevel) { return(_actualImplementation.BeginTransaction(isolationLevel)); }
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); }
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); }
public void Begin(System.Data.IsolationLevel isolatedLevel) { //throw new NotImplementedException(); }
IDbTransaction IDbConnection.BeginTransaction(IsolationLevel il) { return this.BeginTransaction(il); }
public DbContextTransaction BeginTransaction(System.Data.IsolationLevel isolation) => Database.BeginTransaction(isolation);
public DbTransaction BeginTransaction(IsolationLevel isolationLevel) { return this.BeginDbTransaction(isolationLevel); }
/// <summary> /// 开启事物 /// </summary> /// <returns></returns> public void BeginTransaction(System.Data.IsolationLevel isolationLevel) { BaseDB.BaseDataContext.Database.BeginTransaction(); }
/// <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; }