Print Page | Close Window

Using TransactionScope for volatile data

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3088
Printed Date: 13-May-2026 at 6:18pm


Topic: Using TransactionScope for volatile data
Posted By: JohnBloom
Subject: Using TransactionScope for volatile data
Date Posted: 10-Nov-2011 at 10:25am

We have a Silverlight app and have a process on the server that grabs a number from the database and increments the number by one afterwards. We need to make sure that the number is never grabbed at the same time producing duplicate records. There is also logic that tells which number field in the entity to increment, so auto incrementing fields won’t work. In our previous product we use SQL Transactions and they worked great.

I found an implementation for Transactions in Entity Framework here:

http://geekswithblogs.net/SudheersBlog/archive/2010/04/11/139193.aspx -

I there are lots of options transactionscope:

http://enggtech.wordpress.com/2009/10/16/transactionscope-class-system-transactions/ -

I have tried many combinations of these settings and I always get the same error:

“The transaction specified for TransactionScope has a different IsolationLevel than the value requested for the scope.  Parameter name: transactionOptions.IsolationLevel”

Does anybody have an example of doing transactions in Devforce that are outside the CRUD model?



-------------
-John Bloom



Replies:
Posted By: kimj
Date Posted: 11-Nov-2011 at 10:02am
By default DevForce uses a TransactionScope with an IsolationLevel of ReadCommitted for every query or save.  You can change this default by changing the TransactionSettings.Default or setting the TransactionSettings on the QueryStrategy and/or SaveOptions.   For example to change the default:
 
  TransactionSettings.Default = new TransactionSettings(IsolationLevel.ReadCommitted, TimeSpan.FromSeconds(30), true);



Print Page | Close Window