.net核心框架中System.Transaction程序集的TransactionScope的替代方法

编程入门 行业动态 更新时间:2024-10-27 15:27:55
本文介绍了核心框架中System.Transaction程序集的TransactionScope的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

System.Transaction程序集目前不属于核心框架(请参阅 https ://github/dotnet/corefx/issues/2949 ).在我的应用程序(asp核心mvc)中,我需要使用TransactionScope进行事务处理.

The System.Transaction assembly is not part of the core framework at the moment (see github/dotnet/corefx/issues/2949). In my application (asp core mvc) I need to use TransactionScope for transaction handling.

是否存在与核心框架一起使用的替代事务处理?我尝试使用Castle.Transactions作为替代方案,目前还不支持.

Is there an alternative transaction handling which works with the core framework? I have tried to use Castle.Transactions as an alternative, which is also not supported at the moment.

推荐答案

更新2 .NET Core 2.0现已推出.您可以使用此API.请参阅 docs.microsoft. com/en-us/dotnet/api/system.transactions.transactionscope?view = netcore-2.0

Update 2 .NET Core 2.0 is out now. You can use this API. See docs.microsoft/en-us/dotnet/api/system.transactions.transactionscope?view=netcore-2.0

更新 System.Transactions将在 NET Core 2.0.参见 github/dotnet/core/blob/master/roadmap. md 获取即将发布的版本的详细信息.

Update System.Transactions will be available in NET Core 2.0. See github/dotnet/core/blob/master/roadmap.md for details on upcoming releases.

原始答案

System.Transactions(或环境事务)未在.NET Core 1.0.0中实现,但可能在以后的版本中实现.

System.Transactions (or ambient transactions) is not implemented in .NET Core 1.0.0 but may be implemented in future versions.

您可以通过使用显式事务来解决此问题.

You can work around this by using explicit transactions.

using (var connection = new SqlConnection(connectionString)) { connection.Open(); using (var transaction = connection.BeginTransaction()) { // transaction.Commit(); // transaction.Rollback(); } }

更多推荐

.net核心框架中System.Transaction程序集的TransactionScope的替代方法

本文发布于:2023-11-15 19:26:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1597289.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:框架   核心   程序   方法   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!