Establecer opciones en FbTransaction
-
26-12-2019 - |
Pregunta
¿Cómo puedo configurar estas opciones para FbTransaction?
write
nowait
rec_version
read_committed
en mi código para ejecutar instrucciones SQL de inserción/actualización:
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();
}
Solución
Podrías usar FbTransactionOptions
:
FbTransaction transaction = Connection.BeginTransaction(
FbTransactionOptions.ReadCommitted |
FbTransactionOptions.Write|
FbTransactionOptions.RecVersion|
FbTransactionOptions.NoWait |
);
Mira también en IsolationLevel
:
IsolationLevel.ReadUncommitted
IsolationLevel.ReadCommitted
IsolationLevel.RepeatableRead
IsolationLevel.Serializable
Podrías hacerlo:
FbTransaction transaction = Connection.BeginTransaction( IsolationLevel.Serializable );
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow