protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } if (Connection != null) { if (Connection.State != ConnectionState.Closed) { Connection.Close(); } Connection.Dispose(); Connection = null; } } disposedValue = true; } }
private void DoClose() { if (m_connectionState != ConnectionState.Closed) { m_cachedProcedures = null; if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } if (m_session != null) { if (m_connectionSettings.Pooling) { m_session.ReturnToPool(); } else { m_session.DisposeAsync(IOBehavior.Synchronous, CancellationToken.None).GetAwaiter().GetResult(); } m_session = null; } SetState(ConnectionState.Closed); } }
public async Task CommitTransactionAsync(IDbContextTransaction transaction) { if (transaction == null) { throw new ArgumentNullException(nameof(transaction)); } if (transaction != CurrentTransaction) { throw new InvalidOperationException($"Transaction {transaction.TransactionId} is not current"); } try { await SaveChangesAsync(); transaction.Commit(); } catch { RollbackTransaction(); throw; } finally { if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } } }
/// <inheritdoc /> public void Dispose() { CurrentTransaction?.Dispose(); DbConnection?.Close(); DbConnection?.Dispose(); }
public virtual void Dispose() { if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } }
public virtual void Dispose() { CurrentTransaction?.Dispose(); if (_connectionOwned && _connection != null) { _connection.Dispose(); _connection = null; _openedCount = 0; } }
public void Commit() { CurrentTransaction?.Commit(); CurrentTransaction?.Dispose(); if (CurrentConnection?.State == ConnectionState.Open) { CurrentConnection.Close(); } CurrentConnection?.Dispose(); }
/// <summary> /// 事务回滚 /// </summary> public void Rollback() { if (CurrentTransaction == null) { return; } CurrentTransaction.Rollback(); CurrentTransaction.Dispose(); CurrentTransaction = null; }
public void Rollback() { CurrentTransaction?.Rollback(); CurrentTransaction?.Dispose(); if (CurrentConnection?.State == ConnectionState.Open) { CurrentConnection.Close(); } CurrentConnection?.Dispose(); }
public virtual void Dispose() { DbContexts.Clear(); if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } }
public virtual void Commit() { if (CurrentTransaction == null) { return; } CurrentTransaction.Complete(); CurrentTransaction.Dispose(); CurrentTransaction = null; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public virtual void Dispose() { CurrentTransaction?.Dispose(); if (_connectionOwned && _connection.HasValue) { _connection.Value.Dispose(); _connection.Reset(CreateDbConnection); _openedCount = 0; } }
public void Dispose() { if (CurrentTransaction != null) { CurrentTransaction.Dispose(); } if (_connection.IsValueCreated && _connection.Value.State != ConnectionState.Closed) { _connection.Value.Close(); } }
public virtual void Dispose(IIocResolver iocResolver) { foreach (var dbContext in DbContexts) { iocResolver.Release(dbContext); } if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } }
public void Rollback() { if (CurrentTransaction == null) { throw new InvalidOperationException(); } lock (_transactionSyncRoot) { CurrentTransaction.Rollback(); CurrentTransaction.Dispose(); CurrentTransaction = null; } }
/// <summary> /// 保存数据并且提交事务 /// </summary> protected override void CompleteUow() { SaveChanges(); if (CurrentTransaction == null) { return; } CurrentTransaction.Complete(); CurrentTransaction.Dispose(); CurrentTransaction = null; }
/// <summary> /// Fecha a sessão. /// </summary> public void Close() { if (_state == GDASessionState.Open) { if (CurrentTransaction != null) { CurrentTransaction.Dispose(); } _currentConnection.Close(); _currentConnection.Dispose(); CurrentTransaction = null; _currentConnection = null; _state = GDASessionState.Closed; } }
public void Dispose() { foreach (var dbContext in DbContexts) { _dependencyResolver.Release(dbContext); } DbContexts.Clear(); if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } }
public void RollbackTransaction() { try { CurrentTransaction?.Rollback(); } finally { if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } } }
private void DoClose() { if (m_connectionState != ConnectionState.Closed) { if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } if (m_session != null) { if (!m_session.ReturnToPool()) { m_session.Dispose(); } m_session = null; } SetState(ConnectionState.Closed); } }
/// <summary> /// uow完成后自动释放 /// </summary> protected override void DisposeUow() { //DbContext.Dispose(); if (null == Options) { return; } if (Options.IsTransactional == true) { foreach (var dbContext in DbContexts) { IocResolver.Release(dbContext); } DbContexts.Clear(); if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } } else { foreach (var activeDbContext in ActiveDbContexts.Values.ToImmutableList()) { Release(activeDbContext); } } if (CurrentTransaction != null) { CurrentTransaction.Dispose(); CurrentTransaction = null; } ActiveDbContexts.Clear(); }
public override void Complete() { lock (_lock) { _db.SaveChanges(); if (CurrentTransaction != null) { try { CurrentTransaction.Commit(); } catch (System.Exception) { CurrentTransaction.Rollback(); } finally { CurrentTransaction.Dispose(); } } } }
/// <summary> /// 释放资源 /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (Connection != null) { using (Connection) { if (Connection.State != ConnectionState.Closed) { if (CurrentTransaction != null) { CurrentTransaction.Rollback(); CurrentTransaction.Dispose(); } } Connection.Close(); Connection.Dispose(); } } this._isDisposed = true; } }
// Protected implementation of Dispose pattern. protected virtual void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { if (_connection is object) { if (CurrentTransaction is object) { if (!_committed) { CurrentTransaction.Rollback(); } CurrentTransaction.Dispose(); } _connection.Dispose(); } } disposed = true; }
public void Dispose() { CurrentTransaction?.Dispose(); CurrentTransaction = null; _semaphore?.Dispose(); }
public void Dispose() { CurrentTransaction?.Dispose(); _realConnection.Dispose(); }