There is a table called Accounts.The table structure looks like:
有一个表叫做account。表结构如下:
AccountID AccountName AccountTotalMoney
1 Stsven 3000
The account(where AccountID=1) was shared by many users.
许多用户都共享帐户(AccountID=1)。
So when a user updates the account(locking the account),I would like to prevent others updating the account.
因此,当用户更新帐户(锁定帐户)时,我希望防止其他人更新帐户。
I have visited
我访问过
6 ways of doing locking in .NET
在。net中执行锁定的6种方法
But I do not understand yet.Sorry for my bad english. Thanks in advance!
但我还不明白。对不起,我的英语不好。提前谢谢!
1 个解决方案
#1
2
You can use TransactionScope to implement pessimistic locking (change isolation level)
您可以使用TransactionScope实现悲观锁(更改隔离级别)
I think this post can help: Setting the IsolationLevel using the System.Transactions TransactionScope.
我认为这篇文章可以帮助您:使用系统设置隔离级别。TransactionScope事务。
Be aware "pessimistic locking" mentioned in the link you posted is different concept of "pessimistic concurrency". Make sure it is the thing you want.
请注意,您发布的链接中提到的“悲观锁定”是“悲观并发”的不同概念。确保它是你想要的东西。
#1
2
You can use TransactionScope to implement pessimistic locking (change isolation level)
您可以使用TransactionScope实现悲观锁(更改隔离级别)
I think this post can help: Setting the IsolationLevel using the System.Transactions TransactionScope.
我认为这篇文章可以帮助您:使用系统设置隔离级别。TransactionScope事务。
Be aware "pessimistic locking" mentioned in the link you posted is different concept of "pessimistic concurrency". Make sure it is the thing you want.
请注意,您发布的链接中提到的“悲观锁定”是“悲观并发”的不同概念。确保它是你想要的东西。