private void addOrder(object sender, RoutedEventArgs e) { // Add a new Order in a child transaction scope. // Rolling back the child transaction will not roll back the parent transaction. using (var tran2 = new ClientTransaction(_transaction)) // Create a child transaction. { var order = new Order(); var window = new OrderWindow(order, tran2); if (window.ShowDialog() == true) { // Add the order in the child transaction scope and commit the transaction. using (tran2.Scope()) { Customer.Orders.Add(order); tran2.Commit(); } } } // The child transaction will be rolled back automatically if it is not committed. }
private void editOrder(object sender, RoutedEventArgs e) { // Edit the currently selected order in a child transaction. var order = ordersGrid.SelectedItem as OrderInfo; if (order == null) { return; } // Create a child transaciton and edit the order in the child transaction scope. using (var tran2 = new ClientTransaction(_transaction)) { var window = new OrderWindow(order.GetOrder(), tran2); if (window.ShowDialog() == true) { tran2.Commit(); } } // The child transaction will be rolled back automatically if it is not committed. }