System.Transactions.TransactionScope())
    {
        DeleteOrders();
        DeleteCustomers();
        AddNewCustomers();
        AddNewOrders();

        updateTransaction.Complete();
        northwindDataSet.AcceptChanges();
    }
}

 

The order for reconciling changes to related data is as follows:

  • Delete child records (in this case, delete records from the Orders table)

  • Delete parent records (in this case, delete records from the Customers table)

  • Insert parent records (in this case, insert records in the Customers table)

  • Insert child records (in this case, insert records in the Orders table)

相关文章: