c# 业务层事务

步骤:

1.先添加System.Transactions.dll的引用

2.使用System.Transactions命名空间下的类

实例:

using (TransactionScope scope = new TransactionScope()) 

            //你的业务代码 
            scope.Complete(); 


备注:

.NET 2.0的隐式事务是比较完美的,特别是在业务逻辑层...非常不推荐用SqlConnection的事务控制,DAL换数据库怎么办?即使自己实现ITransaction接口也比用SqlConnection这种耦合度极高的方案要好得多...

原文地址:https://www.cnblogs.com/dujinyang/p/4475484.html