c# 业务层事务
时间:2015-05-04 11:33:29
收藏:0
阅读:346
步骤:
1.先添加System.Transactions.dll的引用
2.使用System.Transactions命名空间下的类
实例:
using (TransactionScope scope = new TransactionScope())
{
//你的业务代码
scope.Complete();
}
备注:
.NET 2.0的隐式事务是比较完美的,特别是在业务逻辑层...非常不推荐用SqlConnection的事务控制,DAL换数据库怎么办?即使自己实现ITransaction接口也比用SqlConnection这种耦合度极高的方案要好得多...
原文:http://www.cnblogs.com/dujinyang/p/4475484.html
评论(0)