ado.net - Row-Level Update Lock using System.Transactions -


i have mssql procedure following code in it:

select id, role, jurisdictiontype, jurisdictionkey      dbo.securityassignment with(updlock, rowlock) id = @useridentity 

i'm trying move same behavior component uses oledb connections, commands, , transactions achieve same result. (it's security component uses securityassignment table shown above. want work whether table in mssql, oracle, or db2)

given above sql, if run test using following code

thread backgroundthread = new thread(     delegate()       {         using (var transactionscope = new trasnsactionscope())         {           subject.getassignmentshavinguser(useridentity);           thread.sleep(5000);           backgroundwork();           transactionscope.complete();         }      }); backgroundthread.start();  thread.sleep(3000); var foregroundresults = subject.getassignmentshavinguser(useridentity); 

where subject.getassignmentshavinguser runs sql above , returns collection of results , backgroundwork action updates rows in table, this:

delegate   {     subject.updateassignment(newassignment(user1, role1));   } 

then foregroundresults returned test should reflect changes made in backgroundwork action.

that is, retrieve list of securityassignment table rows have updlock, rowlock applied sql, , subsequent queries against rows don't return until update lock released - foregroundresult in test includes updates made in backgroundthread.

this works fine.

now, want same database-agnostic sql, using oledb transactions , isolation levels achieve same result. , can't life of me, figure out how it. possible, or row-level locking apply @ db level?


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -