LINQ to SQL Transaction.Complete 与 DataContext.SubmitChanges
我在程序中具有以下结构:
Using transaction As New TransactionScope()
'Make some changes to the data
...
db.SubmitChanges()
'Make some other changes to the data
...
db.SubmitChanges()
transaction.Complete()
End Using
当每次调用 SubmitChanges() 时,更改是否会实际保存到数据库,还是只有 transaction.Complete() 才会物理保存它们?我的意思是我不希望 1 个用户所做的中间更改对其他人可见。
I have the following structure in the program:
Using transaction As New TransactionScope()
'Make some changes to the data
...
db.SubmitChanges()
'Make some other changes to the data
...
db.SubmitChanges()
transaction.Complete()
End Using
Will the changes be actually saved to the database when each of SubmitChanges() is called, or only transaction.Complete() will physically save them? I mean I don't want the intermediate changes made by 1 user to be visible to others.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

SubmitChanges 将发送 DML 语句。 Commit 将提交事务。当事务未提交时,其他读者将看不到您的更改。您没有保存部分更改的风险,甚至没有使它们在一段时间内可见的风险。您可以多次调用 SubmitChanges。如果没有显式事务 SubmitChanges 将在内部使用一个事务。
SubmitChanges will send the DML statements. Commit will commit the transaction. While the transaction is not committed, other readers will not see your changes. You have no risk of saving partial changes or even making them visible for a shot period of time. You can call SubmitChanges multiple times. Without an explicit transaction SubmitChanges will use one internally.