• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > 编程与数据库 > net编程 >

LINQ那些事儿(3)- 事务和并发冲突处理(5)

来源: www.dedecms8.com 编辑:织梦吧 时间:2012-06-27点击:

12 }
13 catch (Exception)
14 {
15     context.Transaction.Rollback();
16 }

System.Transactions.TransactionScope version:

01 var context = GenerateContext();
02 Customer customerA = new Customer { CustomerID = "K.K" };
03 Customer customerB = new Customer { CustomerID = "K.K" };
04 context.Customers.InsertOnSubmit(customerA);
05 context.Customers.InsertOnSubmit(customerB);
06
07 try
08 {
09     using (TransactionScope trans = new TransactionScope())
10     {
11         context.SubmitChanges();
12         trans.Complete();
13     }
14 }
15 catch (Exception) {}

About D8

  • ©2014 织梦吧(d8) DedeCMS学习交流平台
  • 唯一网址 www.DedeCMS8.com 网站地图
  • 联系我们 1978130638@qq.com ,  QQ