本文整理汇总了C#中FirebirdSql.Data.FirebirdClient.FbTransaction.BeginTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# FbTransaction.BeginTransaction方法的具体用法?C# FbTransaction.BeginTransaction怎么用?C# FbTransaction.BeginTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FirebirdSql.Data.FirebirdClient.FbTransaction
的用法示例。
在下文中一共展示了FbTransaction.BeginTransaction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginTransaction
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;
}
示例2: Prepare
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();
}
}