Does Serializable transactions only lock out other transactionscope statements? or everything?

In a transaction i have the following, MyEntities is my context:

TransactionOptions options = new TransactionOptions();
options.Timeout = TimeSpan.FromMinutes(1);
options.IsolationLevel = IsolationLevel.Serializable;

 using(TransactionScope scope =

      new TransactionScope(TransactionScopeOption.Required, options))

{
    //Do something to database table MyEntities.Users

}

Does making my isolation level serializable, make it so that if anywhere else in my code I have something like this

MyEntities.Users.First(x=>x.name == "test")

the line of code will wait until the transaction scope is completely done, or does that line of code need to be surrounded in a using(TrnasactionScope... statement in order for it to follow the rules of the transaction isolation level.

Answers


The isolation-level by itself does nothing; what matters is what happens when you start querying data. In particular, you start leaving read-locks all over the place, and key-range locks. If another query hits one of those locks and is reading, then that's fine: read-locks are usually compatible. The isolation-level of the other SPID also matters, obviously - a read-uncommitted SPID won't care about your ongoing operation, where-as higher isolations will.

What starts getting more complex is when one of the SPIDs starts writing data; that can lead to deadlocks if multiple SPIDs already have read-locks on that same data.

But no: a transaction-scope does not block everything else, especially if they are only reading. For what it does do... that is complex, and can only really be analysed on a case-by-case basis.


Need Your Help

Prevent Ctrl+Tab bubling

events actionscript tabs flex3

I'm using ToggleButtonBar control for my Flex project. When user focuses on this control with keyboard it allows him to switch tabs with arrow keys, page up/down or Home/end keys. However, I'd like...

jooq-codegen-maven plugin for different db at the same time

java maven jooq

I use jOOQ and MySQL DB in my application. For integration tests I use H2 database and there is a problem. Is there some way to run jooq-codegen-maven plugin twice? I found some maven example for t...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.