LINQ to SQL Transaction.Complete 与 DataContext.SubmitChanges

发布于 12-29 13:47 字数 356 浏览 4 评论 0原文

我在程序中具有以下结构:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光病人2025-01-05 13:47:27

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文