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的替代方法
发布评论