public FbTransaction BeginTransaction(FbTransactionOptions options, string transactionName) { if (HasActiveTransaction) { throw new InvalidOperationException("A transaction is currently active. Parallel transactions are not supported."); } try { _activeTransaction = new FbTransaction( _owningConnection, IsolationLevel.Unspecified); _activeTransaction.BeginTransaction(options); if (transactionName != null) { _activeTransaction.Save(transactionName); } } catch (IscException ex) { throw new FbException(ex.Message, ex); } return(_activeTransaction); }
public FbTransaction BeginTransaction(FbTransactionOptions options, string transactionName) { EnsureActiveTransaction(); try { _activeTransaction = new FbTransaction(_owningConnection, IsolationLevel.Unspecified); _activeTransaction.BeginTransaction(options); if (transactionName != null) { _activeTransaction.Save(transactionName); } } catch (IscException ex) { DisposeTransaction(); throw new FbException(ex.Message, ex); } return(_activeTransaction); }
public FbTransaction BeginTransaction(IsolationLevel level, string transactionName) { EnsureActiveTransaction(); try { _activeTransaction = new FbTransaction(_owningConnection, level); _activeTransaction.BeginTransaction(); if (transactionName != null) { _activeTransaction.Save(transactionName); } } catch (IscException ex) { DisposeTransaction(); throw FbException.Create(ex); } return(_activeTransaction); }
public async Task <FbTransaction> BeginTransaction(FbTransactionOptions options, string transactionName, AsyncWrappingCommonArgs async) { EnsureActiveTransaction(); try { _activeTransaction = new FbTransaction(_owningConnection, IsolationLevel.Unspecified); await _activeTransaction.BeginTransaction(options, async).ConfigureAwait(false); if (transactionName != null) { _activeTransaction.Save(transactionName); } } catch (IscException ex) { await DisposeTransaction(async).ConfigureAwait(false); throw new FbException(ex.Message, ex); } return(_activeTransaction); }
public async Task <FbTransaction> BeginTransaction(IsolationLevel level, string transactionName, AsyncWrappingCommonArgs async) { EnsureActiveTransaction(); try { _activeTransaction = new FbTransaction(_owningConnection, level); await _activeTransaction.BeginTransaction(async).ConfigureAwait(false); if (transactionName != null) { _activeTransaction.Save(transactionName); } } catch (IscException ex) { await DisposeTransaction(async).ConfigureAwait(false); throw FbException.Create(ex); } return(_activeTransaction); }
private void Prepare(bool returnsSet) { LogCommand(); var innerConn = _connection.InnerConnection; // Check if we have a valid transaction if (_transaction == null) { if (innerConn.IsEnlisted) { _transaction = innerConn.ActiveTransaction; } else { _implicitTransaction = true; _transaction = new FbTransaction(_connection, _connection.ConnectionOptions.IsolationLevel); _transaction.BeginTransaction(); // Update Statement transaction if (_statement != null) { _statement.Transaction = _transaction.Transaction; } } } // Check if we have a valid statement handle if (_statement == null) { _statement = innerConn.Database.CreateStatement(_transaction.Transaction); } // Prepare the statement if needed if (!_statement.IsPrepared) { // Close the inner DataReader if needed DisposeReader(); // Reformat the SQL statement if needed var sql = _commandText; if (_commandType == CommandType.StoredProcedure) { sql = BuildStoredProcedureSql(sql, returnsSet); } try { // Try to prepare the command _statement.Prepare(ParseNamedParameters(sql)); } catch { // Release the statement and rethrow the exception _statement.Release(); _statement = null; throw; } // Add this command to the active command list innerConn.AddPreparedCommand(this); } else { // Close statement for subsequently executions Close(); } }
public FbTransaction BeginTransaction(FbTransactionOptions options, string transactionName) { lock (this) { if (HasActiveTransaction) { throw new InvalidOperationException("A transaction is currently active. Parallel transactions are not supported."); } try { _activeTransaction = new FbTransaction( _owningConnection, IsolationLevel.Unspecified); _activeTransaction.BeginTransaction(options); if (transactionName != null) { _activeTransaction.Save(transactionName); } } catch (IscException ex) { throw new FbException(ex.Message, ex); } } return _activeTransaction; }
private void Prepare(bool returnsSet) { LogCommand(); FbConnectionInternal innerConn = _connection.InnerConnection; // Check if we have a valid transaction if (_transaction == null) { if (innerConn.IsEnlisted) { _transaction = innerConn.ActiveTransaction; } else { _implicitTransaction = true; _transaction = new FbTransaction(_connection, _connection.ConnectionOptions.IsolationLevel); _transaction.BeginTransaction(); // Update Statement transaction if (_statement != null) { _statement.Transaction = _transaction.Transaction; } } } // Check if we have a valid statement handle if (_statement == null) { _statement = innerConn.Database.CreateStatement(_transaction.Transaction); } // Prepare the statement if needed if (!_statement.IsPrepared) { // Close the inner DataReader if needed CloseReader(); // Reformat the SQL statement if needed string sql = _commandText; if (_commandType == CommandType.StoredProcedure) { sql = BuildStoredProcedureSql(sql, returnsSet); } try { // Try to prepare the command _statement.Prepare(ParseNamedParameters(sql)); } catch { // Release the statement and rethrow the exception _statement.Release(); _statement = null; throw; } // Add this command to the active command list innerConn.AddPreparedCommand(this); } else { // Close statement for subsequently executions Close(); } }