Set Isolation level to DIRTY READ in Entity Framework with Informix

1.3k views Asked by At

Is there a way to set isolation levels in Entity Framework 5 with Informix database or LOCK MODE TO WAIT?

I have tried to set isolation using SQL query, at the time of DbContext object creation.

var dataContext = new DatabaseNameContext();  
dataContext.Database.ExecuteSqlCommand("SET ISOLATION TO DIRTY READ");

But it seems this is not working. I am still getting a lock exception:

IBM.Data.DB2.DB2Exception (0x80004005): ERROR [IX000] [IBM][IDS/UNIX64]
Could not do a physical-order read to fetch next row.
(-107 ISAM error: record is locked.

I tried using TransactionScope with System.Transactions.IsolationLevel.ReadUncommitted, but it is throwing the exception:

IBM.Data.DB2.DB2Exception (0x80004005): ERROR [58005] [IBM][IDS/UNIX64]
SQL0998N Error occurred during transaction or heuristic processing.
Reason Code = "16". Subcode = "2-8004D026".

Can you explain what's going wrong and how to fix it?

1

There are 1 answers

0
Neiros On

dataContext.Database.ExecuteSqlCommand("SET LOCK MODE TO WAIT 20");

It works for me :) Might be of use to someone...