Вопрос

Как мне установить для этих параметров значение FbTransaction

write
nowait
rec_version
read_committed

в моем коде для выполнения операторов вставки/обновления sql:

FbConnectionStringBuilder fbConnStr = new FbConnectionStringBuilder();

using (FbConnection fbConn = new FbConnection(fbConnStr))
{
   fbConn.Open();
   using (FbTransaction fbTran = fbConn.BeginTransaction())
   {
      using (FbCommand fbCmd = new FbCommand("insert into TEST values (1)", fbConn, fbTran)
      {
         fbCmd.CommandType = CommandType.Text;
         fbCmd.ExecuteNonQuery();
         fbCmd.Transaction.Commit();
      }
   }
   fbConn.Close();
}
Это было полезно?

Решение

Вы могли бы использовать FbTransactionOptions:

FbTransaction transaction = Connection.BeginTransaction(
    FbTransactionOptions.ReadCommitted  |
    FbTransactionOptions.Write|
    FbTransactionOptions.RecVersion|
    FbTransactionOptions.NoWait |
    );

Посмотрите также на IsolationLevel:

  • IsolationLevel.ReadUncommitted
  • IsolationLevel.ReadCommitted
  • IsolationLevel.RepeatableRead
  • IsolationLevel.Serializable

Вы можете сделать:

FbTransaction transaction = Connection.BeginTransaction( IsolationLevel.Serializable );
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top