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) {}