bltoolkit icon indicating copy to clipboard operation
bltoolkit copied to clipboard

Need to use WITH (NOLOCK) with select queries

Open mfatah14 opened this issue 11 years ago • 6 comments

Hi

I'm using bltoolkit for my application and after deploying it on production environment it was very slow due to read with locking, I have no problem to read dirty data, so how to use WITH (NOLOCK) with my select queries

Thanks

mfatah14 avatar Sep 17 '14 10:09 mfatah14

See an example:

        using (DbManager db = new DbManager())
        {
            db.BeginTransaction(IsolationLevel.ReadUnCommitted);

            // ...

            db.CommitTransaction();
        }

MaratFattakhov avatar Sep 17 '14 10:09 MaratFattakhov

I know that read uncommitted will work but I Use a generic method to get queryable from an entity and I don't know exactly when the query will be executed or else when I'm getting my result ( calling ToList() Method ) I must call commitTransaction after it

Any other solutions

mfatah14 avatar Sep 17 '14 16:09 mfatah14

Is it not possible to use IsolationLevel.ReadUnCommitted without creating a Transaction? Or is it no problem if I create a Transaction for every read call?

jogibear9988 avatar Sep 18 '14 19:09 jogibear9988

that is what I'm saying, I will need to open transaction with any read operation which is not possible with linq deferred execution

mfatah14 avatar Sep 19 '14 13:09 mfatah14

Any solution

mfatah14 avatar Sep 23 '14 05:09 mfatah14

@mfatah14, See this, it can work for you: https://github.com/igor-tkachev/bltoolkit/issues/214#issuecomment-19973814

Though initially I put a question there about query hints, the answers were still useful and allowed me to implement table hints, e.g. "with (nolock)".

kam99 avatar Oct 10 '14 09:10 kam99