c# - 根事务范围不回滚嵌套事务范围
问题描述
我有一个问题,即当根事务范围处置未回滚的嵌套已完成事务范围时。处置根时,我需要回滚所有嵌套的事务范围。
来自根 wcf 服务的根范围
using (var ts = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted, Timeout = new TimeSpan(0, 10, 0) },
TransactionScopeAsyncFlowOption.Enabled))
{
try
{
//logic ... and call the inner scope
ts.Complete();
return result;
}
catch (Exception ex)
{
ts.Dispose();
throw ex;
}
}
另一个 wcf 服务中的嵌套范围
using (var ts = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted, Timeout = new TimeSpan(0, 10, 0) },
TransactionScopeAsyncFlowOption.Enabled))
{
try
{
//logic
ts.Complete();
return result;
}
catch (Exception ex)
{
ts.Dispose();
throw ex;
}
}
我需要当根范围因异常而被处置时,回滚所有内部事务范围
解决方案
推荐阅读
- go - Golang Gorilla mux如何处理不同的端口?
- ios - 从视图模型到视图控制器类的函数调用
- reactjs - 将 Asp.Net Core SignalR 与 React 和 Redux 一起使用是否重要?
- r - Rselenium 的更快替代品
- c# - .NET 核心 2.2。尝试删除时如何摆脱此 HTTP 405 错误?
- react-native - 用户对象在应用程序中是空的,即使它是从后端服务器返回的
- android - Google play 应用内更新 api 可用性和用途
- python - 处理来自模块的异常
- java - Selenium Java -HtmlUnitDriver - 在页面上找不到任何元素?
- python - 如何在 lmplot 的每个轴上绘制注释?