UpdateRule [ForeignKeyConstraint only]
Rulerule
= Constraint.UpdateRule; Constraint.UpdateRule =rule
;
Determines what happens if the parent’s key column
is modified. You can use any value from the Rule
enumeration, as shown in Table 26-3. The default is
Cascade
, which means that the child rows are
updated to point to the new value.
In this example, all the child order records are updated to use the
new CustomerID
value:
// This is the ForeignKeyConstraint for the Orders table. fkc.UpdateRule = Rule.Cascade; // Select the first row. DataRow row = ds.Tables["Customers"].Rows[0]; Console.WriteLine("Modifying: " + row["CustomerID"].ToString()); // Modify the CustomerID (all any linked order records will be updated). row["CustomerID"] = "NEWCUST";