I am attempting to set the Transaction Isolation Level in .NET/C# for a Transaction. I am using the following code to set up the 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, this produces the 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 is it setting the isolation level as 'read committed' when I specifically requested 'snapshot'?
Snapshot isolation has been turned on for the database in question.
This 'read committed' is being blocked by another long running transaction.
Running the following inside the SQL Server Management Studio works just fine during the long running transaction, but the code above is blocked because the isolation level is being changed from what I specified.
USE <database>;
GO
SET TRANSACTION ISOLATION LEVEL SNAPSHOT;
GO
BEGIN TRANSACTION;
GO
<SELECT STATEMENT>
GO
COMMIT TRANSACTION;
GO
WHY?