c# - Setting Transaction Isolation Level in .NET / Entity Framework for SQL Server -
i attempting set transaction isolation level in .net/c# transaction. using following code set transaction:
using (var db = new dbcontext("connectionstring")) { using (var transaction = new transactionscope(transactionscopeoption.requiresnew, new transactionoptions() { isolationlevel = isolationlevel.snapshot })) { ...code here transaction.complete(); } } using sql server profiler, produces following:
set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language us_english set dateformat mdy set datefirst 7 set transaction isolation level read committed why setting isolation level 'read committed' when requested 'snapshot'?
snapshot isolation has been turned on database in question.
this 'read committed' being blocked long running transaction.
running following inside sql server management studio works fine during long running transaction, code above blocked because isolation level being changed specified.
use <database>; go set transaction isolation level snapshot; go begin transaction; go <select statement> go commit transaction; go why?
all new transactionscope set transaction.current. 100% does. want support transactions can @ property , enlist. usual dbconnection classes enlist when opened. apparently, code not open connection while under particular scope.
system.transactions has no built-in support changing isolation level (which sad omission). need yourself.
Comments
Post a Comment