System.Data.Rule Enumeration

Indicates the action that occurs when a System.Data.ForeignKeyConstraint is enforced.

Syntax

public enum Rule

Remarks

The System.Data.Rule values are set to the ForeignKeyConstraint.UpdateRule and the ForeignKeyConstraint.DeleteRule properties of a System.Data.ForeignKeyConstraint object found in a System.Data.DataTable object's System.Data.ConstraintCollection.

The System.Data.Rule values determine the action that occurs when a value in a column is either deleted or updated. Of the two, deleting a value is the more critical and demanding of attention when setting a rule.

In the case where a value is deleted, Cascade specifies that all rows containing that value are also deleted. SetNull specifies that values in all child columns are set to null values. SetDefault specifies that all child columns be set to the default value for the column. None specifies that no action will occur, but exceptions are generated.

In the case where a value is updated, Cascade specifies that all child columns are likewise updated with the new value. SetNull specifies that all child columns be set to null values. SetDefault specifies that all child column values be set to the default value. None specifies that no action be taken, but exceptions are generated.

Constraints on a System.Data.DataSet are not enforced unless the DataSet.EnforceConstraints property is true.

When the DataTable.AcceptChanges method is called, the ForeignKeyConstraint.AcceptRejectRule further determines what action occurs.

Members

Member NameDescription
Cascade

Delete or update related rows. This is the default.

None

No action taken on related rows.

SetDefault

Set values in related rows to the value contained in the DataColumn.DefaultValue property.

SetNull

Set values in related rows to DBNull.

Requirements

Namespace: System.Data
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0