.NET可逆框架设计

开发 架构 后端
前段时间一直在学习和研究.NET事务处理,慢慢的我发现可以使用事务处理来实现一种可逆的系统框架。这种框架在一些IT社区似乎还没有见过,但是在我们日常开发中确实有这个需求。所以我花了点时间深入的研究了一下事务的原理和使用,实现了以事务为纽带,以资源为操作对象的可逆框架。

前段时间一直在学习和研究.NET事务处理,慢慢的我发现可以使用事务处理来实现一种可逆的系统框架。这种框架在一些IT社区似乎还没有见过,但是在我们日常开发中确实有这个需求。所以我花了点时间深入的研究了一下事务的原理和使用,实现了以事务为纽带,以资源为操作对象的可逆框架。

这里我假设您对事务有了整体的认识,也对自定义事务管理器有过了解。[王清培版权所有,转载请给出署名]

(可以参考本人的:.NET简谈事务本质论.NET简谈自定义事务资源管理器)

1.    什么是可逆的程序框架

什么叫可逆的?程序的执行是可以被无限制回滚的。

什么叫可逆的框架?实现了对可逆功能的封装,并能通过简单的接口调用进行使用。框架可能有大有小,我想这么称呼它是为了表达它的整体性和重要性。

那么到底可逆的需求在哪里?其实在我们开发程序的时候经常会使用事务来进行业务的控制。比如删除订单,然后删除订单明细等等,对于这样的要求很多,我们只能将逻辑控制在一个事务范围内,不能在没有事务性的逻辑代码中编写这种要求的业务功能。等出现未知错误的时候在进行事务的回滚。

你也许会问,使用原来的事务处理不是也能进行回滚吗?当然不是这么简单的,我们使用事务回滚时只能将资源回滚到最初未进行事务处理前的状态。(这里不仅仅指的是数据库事务,而是全局的事务处理) 我们用图做个比较。[王清培版权所有,转载请给出署名]

传统的事务处理图:

可逆的事务处理图:

从这两幅图中我们可以很明显的看出,传统的事务处理在事务处理的过程当中无法控制中间数据,也就是说无法对事务处理进行分段,然后在进行统一的提交或回滚。

在可逆框架的事务处理里我们就可以控制事务的执行阶段,在必要的时候我们只需提交或者回滚某一阶段的数据。

1.1环境事务

在可逆框架的事务处理图中,我们看到事务的开始,然后就进行下一步、下一步这样的操作。在每进行一个下一步操作的时候,就是进入到了一个子事务里处理,在.NET中是可以进行事务的嵌套,其实也就是依赖事务Dependent Transaction实现。通过使用环境事务可以让事务性感知代码能自动的识别出您将要使用事务进行操作。所以在每进行下一步操作的时候,只有将当前环境事务切换为您将依赖的子事务才行。如果只是单纯的使用依赖事务对象实例在使用,那么将无法进行诸多其他的事务处理。

2可逆框架的实现原理

由于我们只能控制自定义事务资源管理器的内部实现,所以我们在构建自己的数据处理时问题变的简单多了。

实现可逆框架的核心技术就是使用依赖事务进行事务的克隆操作。将一个大的事务处理逻辑上切割成多了小的事务操作,然后在进行统一的提交或回滚。

在实现上其实就是将Committable Transaction对象进行包装,实现简单的调用接口。这里参照了环境代码的概念,将对象的生命周期控制在代码片段中。

2.1自定义资源管理器的实现

我们需要扩展IEnlistmentNotification接口的实现,加入对“上一步”、“下一步”的数据操作。

请看代码:

View Code   
 /***  
  * author:深度训练  
  * blog:http://wangqingpei557.blog.51cto.com/  
  * **/ 
 using System;  
 using System.Collections.Generic;  
 using System.Text;  
 using System.Transactions;  
   
 namespace ReversibleLib  
 {  
     /// <summary>  
     /// 可逆范围内的资源管理器。  
     /// 可以使用该类对易失性资源进行事务范围内的管理。在事务操作范围内进行可逆操作。  
     /// </summary>  
     /// <typeparam name="T">需要管理的资源类型</typeparam>  
     /// <typeparam name="Xcopy">资源在使用、恢复过程中的数据复制对象。</typeparam>  
     public class ReResourceManager<T, Xcopy> : IEnlistmentNotification, IReversibleGetResourceData<T>  
         where T : classnew()  
         where Xcopy : class 
     {  
         /// <summary>  
         /// 私有字段。资源的持久引用。  
         /// </summary>  
         T _commitfrontvalue;  
         /// <summary>  
         /// 私有字段。事务性操作数据对象。  
         /// </summary>  
         T _rollbackfrontvalue = new T();  
         /// <summary>  
         /// 保存数据复制对象。  
         /// </summary>  
         Xcopy _copy;  
         /// <summary>  
         /// 泛型约束需要,内部使用。  
         /// </summary>  
         public ReResourceManager() { }  
         /// <summary>  
         /// 资源管理器内部名称。便于追踪  
         /// </summary>  
         public string Name { getset; }  
         /// <summary>  
         /// 重载默认构造函数,使用资源类型和数据复制对象初始化资源管理器。  
         /// </summary>  
         public ReResourceManager(T t, Xcopy icopy)  
         {  
             (icopy as IResourceCopy<T>).Copy(_rollbackfrontvalue, t);  
             _commitfrontvalue = t;  
             _copy = icopy;  
         }  
   
         #region IEnlistmentNotification 成员  
         public void Prepare(PreparingEnlistment preparingEnlistment)  
         {  
             preparingEnlistment.Prepared();  
         }  
         public void Commit(Enlistment enlistment)  
         {  
             enlistment.Done();  
         }  
         public void InDoubt(Enlistment enlistment)  
         {  
             enlistment.Done();  
         }  
         public void Rollback(Enlistment enlistment)  
         {  
             (_copy as IResourceCopy<T>).Copy(_commitfrontvalue, _rollbackfrontvalue);//回滚事务  
             enlistment.Done();  
         }  
         #endregion  
   
         #region IReversibleGetResourceData<T> 成员  
         T IReversibleGetResourceData<T>.GetPreviousData()  
         {  
             T result = new T();  
             (_copy as IResourceCopy<T>).Copy(result, _rollbackfrontvalue);  
             return result;  
         }  
         T IReversibleGetResourceData<T>.GetNextData()  
         {  
             T result = new T();  
             (_copy as IResourceCopy<T>).Copy(result, _commitfrontvalue);  
             return result;  
         }  
         #endregion  
     }  
 } 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.

#p#

2.2可逆框架的入口实现

我们需要简单的调用就能方便的使用可逆功能,不能以一种新的方式使用。所以这里借鉴了Transaction Scope的设计思想。

请看代码:

View Code   
 /***  
  * author:深度训练  
  * blog:http://wangqingpei557.blog.51cto.com/  
  * **/ 
 using System;  
 using System.Collections.Generic;  
 using System.Text;  
 using System.Transactions;  
   
 namespace ReversibleLib  
 {  
     /// <summary>  
     /// 使代码成为可逆框架的事务性代码  
     /// </summary>  
     public class ReversibleManagerScope : IDisposable  
     {  
         /// <summary>  
         /// 初始化ReversibleManagerScope新的实例  
         /// </summary>  
         public ReversibleManagerScope()  
         {  
             ReversibleManager._reversibleManager = new ReversibleManager();  
         }  
         /// <summary>  
         /// 使用ReversibleManager对象构造ReversibleManagerScope使用范围对象  
         /// </summary>  
         /// <param name="manager">ReversibleManager实例</param>  
         public ReversibleManagerScope(ReversibleManager manager)  
         {  
             ReversibleManager._reversibleManager = manager;  
         }  
         /// <summary>  
         /// 使用自定义资源管理器构造ReversibleManagerScope包装的环境ReversibleManager.Current中的对象实例。  
         /// </summary>  
         /// <param name="source">IEnlistmentNotification资源管理器</param>  
         public ReversibleManagerScope(IEnlistmentNotification source)  
         {  
             ReversibleManager._reversibleManager = new ReversibleManager(source);  
         }  
         /// <summary>  
         /// 全局上下文ReversibleManager对象销毁  
         /// </summary>  
         public void Dispose()  
         {  
             ReversibleManager._reversibleManager = null;  
         }  
         /// <summary>  
         /// 完成整个操作的提交。该操作将提交事务栈中的所有依赖事务  
         /// </summary>  
         public void Completed()  
         {  
             ReversibleManager.Current.Commit();  
         }  
     }  
     /// <summary>  
     /// 可逆模块的入口。  
     /// ReversibleManager对事务对象的封装,实现阶段性的事务提交和回滚。  
     /// </summary>  
     public class ReversibleManager  
     {  
         #region 上下文静态ReversibleManager实例  
         /// <summary>  
         /// 持有对可逆框架的对象引用  
         /// </summary>  
         internal static ReversibleManager _reversibleManager;  
         /// <summary>  
         /// 获取当前上下文中可逆框架  
         /// </summary>  
         public static ReversibleManager Current  
         {  
             get { return _reversibleManager; }  
         }  
         #endregion  
   
         #region 构造对象  
         /// <summary>  
         /// 默认构造函数  
         /// </summary>  
         public ReversibleManager() { }  
         /// <summary>  
         /// 表示可提交的事务(主事务)  
         /// </summary>  
         private CommittableTransaction _commiTransaction;  
         /// <summary>  
         /// 支持两阶段提交协议的资源管理器(主资源管理器)  
         /// </summary>  
         private IEnlistmentNotification _resourceManager;  
         /// <summary>  
         /// 重载构造函数,使用自定义资源管理器构造可逆模块的开始。  
         /// </summary>  
         /// <param name="resource">IEnlistmentNotification接口对象</param>  
         public ReversibleManager(IEnlistmentNotification resource)  
         {  
             _resourceManager = resource;  
             InitLoad(IsolationLevel.Serializable);  
         }  
         /// <summary>  
         /// 重载构造函数,使用自定义资源管理器、内部事务范围的事务隔离级别构造可逆模型的开始。  
         /// </summary>  
         /// <param name="resource">IEnlistmentNotification接口对象</param>  
         /// <param name="isolationlevel">IsolationLevel枚举成员</param>  
         public ReversibleManager(IEnlistmentNotification resource, IsolationLevel isolationlevel)  
         {  
             _resourceManager = resource;  
             InitLoad(isolationlevel);  
         }  
         /// <summary>  
         /// 事务初始化阶段的参数对象  
         /// </summary>  
         TransactionOptions _options;  
         /// <summary>  
         /// 重载构造函数,使用自定义资源管理器、内部事务范围的事务隔离级别、事务超时时间范围构造可逆模块的开始。  
         /// </summary>  
         /// <param name="resource">IEnlistmentNotification接口对象</param>  
         /// <param name="isolationlevel">IsolationLevel枚举成员</param>  
         /// <param name="span">TimeSpan时间范围</param>  
         public ReversibleManager(IEnlistmentNotification resource, IsolationLevel isolationlevel, TimeSpan span)  
         {  
             _options = new TransactionOptions();  
             _options.Timeout = span;  
             InitLoad(isolationlevel);  
         }  
         /// <summary>  
         /// 构造CommittableTransaction对象实例。  
         /// </summary>  
         /// <param name="level">事务隔离级别</param>  
         private void InitLoad(IsolationLevel level)  
         {  
             if (_options == null)  
                 _options = new TransactionOptions();  
             _options.IsolationLevel = level;  
             _commiTransaction = new CommittableTransaction(_options);  
             _commiTransaction.EnlistVolatile(_resourceManager, EnlistmentOptions.None);  
             //作为事务栈的头开始整个可逆结构。  
             _tranStack.Push(_commiTransaction);//压入事务栈  
             _resourceStack.Push(_resourceManager);//压入资源栈  
             //设置环境事务,让所有支持事务性感知框架的代码都能执行。  
             Transaction.Current = _commiTransaction;  
         }  
         #endregion  
   
         /// <summary>  
         /// 事务栈,依次存放事务。  
         /// </summary>  
         private System.Collections.Generic.Stack<Transaction> _tranStack = new Stack<Transaction>();  
         /// <summary>  
         /// 资源栈,依次存放事务使用的资源。  
         /// </summary>  
         private System.Collections.Generic.Stack<IEnlistmentNotification> _resourceStack = new Stack<IEnlistmentNotification>();  
         /// <summary>  
         /// 阶段性事件委托  
         /// </summary>  
         /// <param name="tran">Transaction环境事务</param>  
         public delegate void PhaseHanlder(System.Transactions.Transaction tran);  
         /// <summary>  
         /// 下一步事件  
         /// </summary>  
         public event PhaseHanlder NextEvent;  
         /// <summary>  
         /// 上一步事件  
         /// </summary>  
         public event PhaseHanlder PreviousEvent;  
         /// <summary>  
         /// 开始下一步操作  
         /// </summary>  
         /// <typeparam name="S">IEnlistmentNotification接口实现</typeparam>  
         /// <param name="level">IsolationLevel事务的隔离级别(对全局事务处理设置)</param>  
         /// <param name="source">下一步操作的自定义数据管理器</param>  
         public void Next<S>(IsolationLevel level, S source)  
             where S : class,IEnlistmentNotification, new()  
         {  
             Transaction tran = _tranStack.Peek();//获取事务栈的顶端事务  
             if (tran == null)  
                 tran = Transaction.Current;//主事务  
             DependentTransaction depentran = tran.DependentClone(DependentCloneOption.BlockCommitUntilComplete);  
             //将本次事务处理的资源管理器压入资源栈中  
             depentran.EnlistVolatile(source, EnlistmentOptions.None);  
             _tranStack.Push(depentran);  
             _resourceStack.Push(source);  
             //切换环境事务场景  
             Transaction.Current = depentran;  
             if (NextEvent != null)  
                 if (NextEvent.GetInvocationList().Length > 0)  
                     NextEvent(Transaction.Current);  
         }  
         /// <summary>  
         /// 返回上一步操作  
         /// </summary>  
         /// <typeparam name="T">需要接受的数据对象类型</typeparam>  
         /// <param name="refadd">需要接受的数据对象引用</param>  
         public void Previous<T>(out T refadd) where T : class,new()  
         {  
             Transaction tran = _tranStack.Pop();  
             if (tran == null)//顶层事务  
                 Transaction.Current.Rollback();  
             // tran.Rollback();//回滚本事务,将触发所有克隆事务的回滚。  
             if (PreviousEvent != null)  
                 if (PreviousEvent.GetInvocationList().Length > 0)  
                 {  
                     //设置上一步数据对象  
                     refadd = (_resourceStack.Pop() as IReversibleGetResourceData<T>).GetPreviousData();  
                     PreviousEvent(Transaction.Current);  
                     return;  
                 }  
             refadd = new T();//事务处理异常  
         }  
         /// <summary>  
         /// 提交事物堆栈中的所有事物  
         /// </summary>  
         public void Commit()  
         {  
             if (Transaction.Current is DependentTransaction)  
                 (Transaction.Current as DependentTransaction).Complete();  
             for (int i = 0; i < _tranStack.Count - 1; i++)  
             {  
                 //依赖事务  
                 (_tranStack.Pop() as DependentTransaction).Complete();  
             }  
             //提交事务,主事务。必须进行克隆主体的提交才能完成所有阶段的操作。  
             (_tranStack.Pop() as CommittableTransaction).Commit();  
         }  
         /// <summary>  
         /// 回滚事物堆栈中的所有事物  
         /// </summary>  
         public void RollBack()  
         {  
             if (Transaction.Current is DependentTransaction)  
                 (Transaction.Current as DependentTransaction).Rollback();  
             for (int i = 0; i < _tranStack.Count - 1; i++)  
             {  
                 //依赖事务  
                 (_tranStack.Pop() as DependentTransaction).Rollback();  
             }  
             //提交事务,主事务。必须进行克隆主体的提交才能完成所有阶段的操作。  
             (_tranStack.Pop() as CommittableTransaction).Rollback();  
         }  
     }  
 } 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 160.
  • 161.
  • 162.
  • 163.
  • 164.
  • 165.
  • 166.
  • 167.
  • 168.
  • 169.
  • 170.
  • 171.
  • 172.
  • 173.
  • 174.
  • 175.
  • 176.
  • 177.
  • 178.
  • 179.
  • 180.
  • 181.
  • 182.
  • 183.
  • 184.
  • 185.
  • 186.
  • 187.
  • 188.
  • 189.
  • 190.
  • 191.
  • 192.
  • 193.
  • 194.
  • 195.
  • 196.
  • 197.
  • 198.
  • 199.
  • 200.
  • 201.
  • 202.
  • 203.
  • 204.
  • 205.
  • 206.
  • 207.
  • 208.
  • 209.
  • 210.
  • 211.
  • 212.
  • 213.
  • 214.
  • 215.
  • 216.
  • 217.
  • 218.
  • 219.
  • 220.
  • 221.
  • 222.
  • 223.
  • 224.
  • 225.
  • 226.
  • 227.
  • 228.
  • 229.
  • 230.
  • 231.
  • 232.
  • 233.
  • 234.
  • 235.
  • 236.
  • 237.
  • 238.
  • 239.

3.示例

这里我使用了一个简单的String Builder作为资源管理器需要管理的对象。

请看代码:

View Code   
 /***  
  * author:深度训练  
  * blog:http://wangqingpei557.blog.51cto.com/  
  * **/ 
 using System;  
 using System.Collections.Generic;  
 using System.Text;  
 using System.Data;  
 using System.Transactions;  
 using ReversibleLib;  
   
 namespace ConsoleApplication1  
 {  
     class Program  
     {  
         static void Main(string[] args)  
         {  
             //构造数据  
             StringBuilder strbuilder = new StringBuilder();  
             strbuilder.Append("0");//初始数据为0  
   
             //资源管理器  
             ReResourceManager<StringBuilder, StringBuilderCopy> strResource =  
                 new ReResourceManager<StringBuilder, StringBuilderCopy>(strbuilder, new StringBuilderCopy());  
             strResource.Name = "0资源管理器";  
             //开始进入可逆框架处理环境  
             using (ReversibleManagerScope reversible = new ReversibleManagerScope(strResource))  
             {  
                 try 
                 {  
                     ReversibleManager.Current.PreviousEvent += new ReversibleManager.PhaseHanlder(Current_PreviousEvent);  
                     ReversibleManager.Current.NextEvent += new ReversibleManager.PhaseHanlder(Current_NextEvent);  
                     strbuilder.Append("1");//首次修改数据为01  
   
                     //获取下一步操作的数据  
                     StringBuilder strbuilder2 = (strResource as IReversibleGetResourceData<StringBuilder>).GetNextData();  
                     //构造下一步操作的自定义资源管理器  
                     ReResourceManager<StringBuilder, StringBuilderCopy> strResource2 =  
                         new ReResourceManager<StringBuilder, StringBuilderCopy>(strbuilder2, new StringBuilderCopy());  
                     strResource2.Name = "2资源管理器";  
                     ReversibleManager.Current.Next<ReResourceManager<StringBuilder, StringBuilderCopy>>(  
                         System.Transactions.IsolationLevel.Serializable, strResource2);  
                     strbuilder2.Append("2");//第二步修改数据为012  
   
                     //返回上一步,也就是回滚对数据进行“2”设置的前一个状态  
                     StringBuilder strbuilder3;  
                     ReversibleManager.Current.Previous<StringBuilder>(out strbuilder3);//获取上一步使用的数据,这里应该是01  
   
                     reversible.Completed();//提交所有操作  
                     Console.WriteLine(strbuilder3);  
                 }  
                 catch (Exception err)  
                 { Console.WriteLine(err.Message); ReversibleManager.Current.RollBack(); }  
             }  
             Console.ReadLine();  
         }  
   
         static void Current_NextEvent(Transaction tran)  
         {  
             Console.WriteLine("下一步:" + tran.TransactionInformation.LocalIdentifier);  
             Console.WriteLine("下一步:" + tran.TransactionInformation.DistributedIdentifier);  
         }  
         static void Current_PreviousEvent(Transaction tran)  
         {  
             Console.WriteLine("上一步:" + tran.TransactionInformation.LocalIdentifier);  
             Console.WriteLine("上一步:" + tran.TransactionInformation.DistributedIdentifier);  
         }  
     }  
 } 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.

这里我使用0作为资源的初始数据,然后进入到第一个环节,我将它附加了1,然后进入到第二个环节,我将它附加了2,这里应该是012了,但是下面我突然又返回到了上一步,所以最后的数据应该是01。如果我们需要使用复杂的数据对象,如常用的Data Table类型,我们一般都是用它来展现一组数据,然后对这组数据进行一系列的操作。

总结:

这篇文章主要是想介绍一下事务的另一种使用方式,对可逆框架的设计方向算是一个抛砖引玉吧,希望大家用的着。

源码地址:http://files.cnblogs.com/wangiqngpei557/Reversible.zip

原文链接:http://www.cnblogs.com/wangiqngpei557/archive/2012/06/24/2560576.html

责任编辑:林师授 来源: 博客园
相关推荐

2012-06-25 09:28:42

.NET可逆框架

2016-03-23 11:05:58

Socket开发框架分析

2012-01-18 10:20:42

框架设计

2020-07-30 10:35:32

Java反射框架设计

2009-09-08 09:12:12

LINQ构建框架设计

2010-09-25 13:09:39

UISymbian

2012-01-10 10:04:43

Node.js

2011-04-22 09:26:57

MVC设计

2022-06-15 11:01:59

自定义SPIJava

2021-02-23 08:18:04

Java 反射机制

2022-10-10 09:11:12

互联网存储系统云计算

2022-09-15 18:32:13

SPI模型框架

2022-09-25 21:45:54

日志平台

2017-04-12 23:33:38

DevOps平衡计分卡框架

2022-04-03 15:44:55

Vue.js框架设计设计与实现

2014-09-23 10:05:55

2013-09-09 10:48:24

iOS无线客户端框架设计

2013-09-03 09:35:48

无线客户端框架设计iOS

2013-09-03 09:55:42

iOS无线客户端框架设计

2022-12-16 12:16:21

点赞
收藏

51CTO技术栈公众号