DB2 Entity Framework "WITH UR" transaction isolation

I am trying to use " WITH UR " in every request that goes to db2. Does anyone know how to use transaction isolation in db2 ef4? I want linq to create the following query for me:

SELECT EmployeeID FROM Payroll.Employees WITH UR;

Note. I have already tried using TransactionScope provided in the .net framework 4.0; it does not help at all.

+4
source share
1 answer

Suppose sDB2ConnectionString is the string that you use to connect to DB2.

The isolation level is specified in the transaction, but the Transaction.IsolationLevel property is read-only. You can install it only when creating a transaction.

For simplicity, I used a call to a stored procedure with no parameters. Of course, you can use any type of DB2Command as part of a transaction.

 // string sDB2ConnectionString = ConfigurationManager.AppSettings[environment + "_ConnectionString"]; using ( DB2Connection conn = new DB2Connection( sDB2ConnectionString ) ) { conn.Open(); using ( DB2Transaction tran = conn.BeginTransaction( IsolationLevel.ReadUncommitted ) ) { using ( DB2Command dbCommand = conn.CreateCommand() ) { dbCommand.Transaction = tran; dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "MySchema.MyStoredProcedureName"; dbCommand.ExecuteNonQuery(); tran.Commit(); } } } 
0
source

Source: https://habr.com/ru/post/1402041/


All Articles