CallAMethodThatDoesSomeWork
全部标签 我一直想尝试使用TransactionScope,但我就是想不通人们看到它有什么用处。那么让我们举个例子:using(TransactionScopetran=newTransactionScope()){CallAMethodThatDoesSomeWork1();CallAMethodThatDoesSomeWork2();tran.Complete();}所以最基本的问题是:我如何编写“CallAMethodThatDoesSomeWork1()”,以便它知道如何在我们说“CallAMethodThatDoesSomeWork2()”时回滚其操作抛出异常?
我一直想尝试使用TransactionScope,但我就是想不通人们看到它有什么用处。那么让我们举个例子:using(TransactionScopetran=newTransactionScope()){CallAMethodThatDoesSomeWork1();CallAMethodThatDoesSomeWork2();tran.Complete();}所以最基本的问题是:我如何编写“CallAMethodThatDoesSomeWork1()”,以便它知道如何在我们说“CallAMethodThatDoesSomeWork2()”时回滚其操作抛出异常?