English 中文(简体)
• 使用系统进行网上更新。
原标题:Row-Level Update Lock using System.Transactions

我有一个包含以下法典的MSSQL程序:

SELECT Id, Role, JurisdictionType, JurisdictionKey
FROM 
    dbo.SecurityAssignment WITH(UPDLOCK, ROWLOCK)
WHERE Id = @UserIdentity

我试图将同一行为移至使用OlegDb联系、指挥和交易实现同样结果的组成部分。 (它是一个使用上文所示安保安排表的安全构成部分。) 我想要的是,这个表格是否位于MSSQL、Oracle或Db2。

鉴于上述情况,如果我使用以下代码进行测试的话。

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 the sql above and returns a collection of results and backgroundWork is an Action that updates rows in the table, like this:

delegate
  {
    Subject.UpdateAssignment(newAssignment(user1, role1));
  }

Then the foregroundResults returned by the test should reflect the changes made in the backgroundWork action.

也就是说,我找回一份列有UPDLOCK、ROWLOCK应用的安全安排表浏览器清单,以及随后对这些浏览点的询问,直到这一更新的24小时获释为止,因此测试的地下结果包括背景图中所作的更新。

这一切都是罚款。

现在,我要与数据库分析一样,利用OlegDb交易和孤立水平实现同样的结果。 这对我来说,是怎样做的。 是否甚至有可能,或者这种滚动的锁定只适用于干 the级?

问题回答

暂无回答




相关问题
ADO.NET Entity Data Model are not precise enough

I run this code: var cos = from k in _db.klienci_do_trasy where k.klient_id == 5 select k; but the query send to database is: SELECT * FROM `klienci_do_trasy` LIMIT 0, 30 why is it for, there ...

Synchronising SQL database through ADO.Net

The problem that i m having is how can i synchronise my datasets in my VS 2008 project to any changes in the database. As you know we read data from the db into the dataset which is disconnected, now ...

ADO.NET Data Services - Uploading files

I am trying to write REST web service through which our clients can upload a file on our file server. IS there an example or any useful links which I can refer for any guidance? I haven t seen many ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

热门标签