在 .Net 中,我可以指定默认的应用程序范围隔离级别吗?

发布于 2024-07-14 19:23:22 字数 291 浏览 4 评论 0原文

当我使用 TransactionScope 对象时,我可以指定隔离级别 使用事务选项

如果未指定,则使用的默认隔离级别是什么?

是否可以设置 TransactionScope 使用的应用程序范围的默认隔离级别?

When I am using a TransactionScope object I can specify the Isoaltion Level using the transaction options.

What is the default isolation level used if none is specified?

Is it possible to set an application wide default isolation level that would be used by the TransactionScopes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

浊酒尽余欢 2024-07-21 19:23:22

您可以创建自己的对象来包装 TransactionScope,设置正确的隔离级别,然后使用它代替 TransactionScope。

我不能保证这会起作用,但听起来似乎有道理。 如果确实如此,请告诉我,我会更新答案。

You could create your own object to wrap the TransactionScope, setting the correct Isolation level, then use that in place of a TransactionScope.

I can't guarantee this would work, but sounds plausible. Let me know if it does and I'll update the answer.

野鹿林 2024-07-21 19:23:22

我们只有一个辅助方法 TransactionManager.CreateTransactionScope,它使用项目范围的选项创建一个。 它也是封装其他逻辑的有用位置,例如,如果存在环境事务,您可以使用它,或者创建具有兼容选项的嵌套事务,或者创建一个新事务,具体取决于适合您的应用程序的事务(您可能想要创建重载指定允许哪些行为)。

We just have a helper method TransactionManager.CreateTransactionScope which creates one with the project-wide options. It's also a useful place to encapsulate additional logic such as if there is an ambient transaction you can either use that, or create a nested transaction with compatible options, or create a new transaction, depending on what suits your application (you may want to create overloads specifying which of these behaviours are allowed).

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