Need help using transaction area

I am working on an analysis and preventative measure for a dead end in an application where I found the following line of code for a transaction scope:

var tranaction = new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted };

// TransactionScopeOption.Required changed to Suppress for 2 tier issue with MSDTC
using (var transactionScope = new TransactionScope(TransactionScopeOption.Suppress, tranaction))
{
   //Select entity command.
}

We have only an operator selectthat will allow you to perform dirty read operations. I read some resources on TransactionScopeOption, but I don’t find the exact one TransactionScopeOptionin this case, or I feel that we can change the parameter RequiredNewand create a new transaction every time I execute the select command. Need help moving forward. We use SQL Server as a data source. If we change it to RequiredNew, what will be the impact of performance since this change will be made for the entire select entity command in the application?

+4
source share
2 answers

If you really want to IsolationLevelbe ReadUncommitted, you should not use TransactionScopeOption.Suppress.

Usage TransactionScopeOption.Suppresswill not be involved in any Transaction, but IsolationLevelwill always be used by default for the default database IsolationLevel.ReadCommittedon the SQL server.

You need to either join the transaction Ambientor create a new transaction on IsolationLevel.ReadUncommitted.

So you can definitely go on TransactionScopeOption.RequiredNewto allow dirty reads if you need to.

EDIT
Short answer: way

:
MS DTC TransactionScope.

SQL Server -, SQL Server 2008 , , .

, TransactionScope, . , , MS DTC.

RequiresNew TransactionScope , Ambient Scope. , . - DB , .

+4

, .

, - - RequiredNew , , :

enter image description here

RequiredNew? , , , . SO.

+2

All Articles