首页 > 解决方案 > 根事务范围不回滚嵌套事务范围

问题描述

我有一个问题,即当根事务范围处置未回滚的嵌套已完成事务范围时。处置根时,我需要回滚所有嵌套的事务范围。

来自根 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;
            }

        }

我需要当根范围因异常而被处置时,回滚所有内部事务范围

标签: c#wcftransactionssoatransactionscope

解决方案


推荐阅读