Insert 方法是在OrderSynchronous.cs 调用
using(var ts = new TransactionScope(TransactionScopeOption.Required)) { |
dal.Insert(order); //这里的dal就是SQLServerDAL.Order类 |
// Update the inventory to reflect the current inventory after the order submission |
var inventory = new InventoryService(); |
inventory.TakeStock(order.LineItems); |
// Calling Complete commits the transaction. |
// Excluding this call by the end of TransactionScope's scope will rollback the transaction |
ts.Complete(); |
} 如果出错既不会执行ts.Complete();提交事务 |