.net 使用类型化数据集和Sql Server CE的事务

.net 使用类型化数据集和Sql Server CE的事务,.net,winforms,transactions,sql-server-ce,strongly-typed-dataset,.net,Winforms,Transactions,Sql Server Ce,Strongly Typed Dataset,我有一个与SqlCe本地数据库交互的WinForms应用程序。我使用BindingSources、TableAdapters和类型化数据集管理db操作。我有几个操作分散在两个不同类中的几个方法中,我需要在事务中执行这些操作,我正在考虑使用System.Transactions.transaction或CommitableTransaction。我的问题是,Transaction或CommitteableTransaction是否会在事务中成功工作并在示例代码中出现错误时回滚,或者我是否也必须在其

我有一个与SqlCe本地数据库交互的WinForms应用程序。我使用BindingSources、TableAdapters和类型化数据集管理db操作。我有几个操作分散在两个不同类中的几个方法中,我需要在事务中执行这些操作,我正在考虑使用System.Transactions.transaction或CommitableTransaction。我的问题是,Transaction或CommitteableTransaction是否会在事务中成功工作并在示例代码中出现错误时回滚,或者我是否也必须在其他类方法中使用Transaction

OtherClass othercls = new OtherClass();  
...  

private void DoAll()  
{  
/* begin transaction here */
this.tableAdapter.DoSomeDBWork();  
othercls.DeleteSomeRecords(); //uses tableadapter+sql code to delete. throws exception on error. doesn't have transaction  
othercls.DeletOtherRecords(); //uses tableAdapter.Rows.Find(id).Delete(). throws exception on error. doesn't have transaction  
othercls.Update(); //uses tableadapter.Update(). throws exception on error. doesn't have transaction  
this.DeleteSomeFiles(); //throws exception on fail 
/* end transaction here */ 
}  
尝试System.Transactions。

根据System.Transaction.TransactionScope部分

如果异常确实发生在事务范围内,则它参与的事务将被回滚

尝试System.Transactions。

根据System.Transaction.TransactionScope部分

如果异常确实发生在事务范围内,则它参与的事务将被回滚