Print Page | Close Window

isolation level

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=2512
Printed Date: 26-Apr-2025 at 5:08am


Topic: isolation level
Posted By: BillG
Subject: isolation level
Date Posted: 16-Feb-2011 at 12:08pm
Can you provide an example of setting the isolation level?
 
Bascially what I need is I have a method that grabs the next invoice # from a table, increments it and saves it back to the table. I want the above to be part of the same transaction and I want to block other users from grabbing a number until another user has written back the next number.
 
Bill
 



Replies:
Posted By: DenisK
Date Posted: 16-Feb-2011 at 3:47pm
Hi BillG;

Here's an example. 1 for saving, 1 for querying.

TransactionSettings settings = new TransactionSettings(System.Transactions.IsolationLevel.ReadCommitted, 
                                                                                         new TimeSpan(0, 1, 0));

mgr.DefaultSaveOptions.TransactionSettings = settings;

TransactionSettings settings2 = new TransactionSettings(System.Transactions.IsolationLevel.Serializable, 
                                                                                         new TimeSpan(0, 1, 0));

QueryStrategy qs = new QueryStrategy(QueryStrategy.Normal, settings2);
mgr.DefaultQueryStrategy = qs;

And the link to our DRC that briefly talks about this. 

http://drc.ideablade.com/xwiki/bin/view/Documentation/Transactional-Queries - http://drc.ideablade.com/xwiki/bin/view/Documentation/Transactional-Queries

Hope this helps.



Print Page | Close Window