This ensures that each DataRow in your child DataTable has a matching DataRow in your parent DataTable.. Table 12.2: ForeignKeyConstraint PROPERTIES PROPERTY TYPE DESCRIPTION AcceptReje
Trang 1The ForeignKeyConstraint Class
You use an object of the ForeignKeyConstraint class to represent a foreign key constraint between two DataTable objects This ensures that each DataRow in your child DataTable has a matching DataRow in your parent DataTable The ForeignKeyConstraint class is derived from the System.Data.Constraint class Table 12.2 shows the
ForeignKeyConstraint properties
Table 12.2: ForeignKeyConstraint PROPERTIES
PROPERTY TYPE DESCRIPTION
AcceptRejectRule AcceptRejectRule Gets or sets the AcceptRejectRule that indicates
the action that is to take place when the AcceptChanges() method of the DataTable is called
The members of the System.Data.AcceptRejectRule enumeration are
• Cascade, which indicates that the changes
to the DataRow objects in the parent DataTable are also made in the child DataTable
• None, which indicates that no action takes place
The default is None
Columns DataColumn[] Gets the array of DataColumn objects from the
child DataTable
ConstraintName string Gets the name of the UniqueConstraint object DeleteRule Rule Gets or sets the Rule that indicates the action that
is to take place when a DataRow in the parent DataTable is deleted
The members of the System.Data.Rule enumeration are
• Cascade, which indicates that the delete
or update to the DataRow objects in the parent DataTable is also made in the child DataTable
Trang 2Table 12.2: ForeignKeyConstraint PROPERTIES
PROPERTY TYPE DESCRIPTION
• None, which indicates that no action takes place
• SetDefault, which indicates that the DataColumn values in the child DataTable are to be set to the value in the DefaultValue property of the
DataColumn
• SetNull, which indicates that the DataColumn values in the child DataTable are to be set to DBNull
The default is Cascade
ExtendedProperties PropertyCollection Gets the PropertyCollection object that you can
use to store strings of additional information RelatedColumns DataColumn[] Gets the array of DataColumn objects in the
parent DataTable for the UniqueConstraint RelatedTable DataTable Gets the parent DataTable for the
UniqueConstraint
Table DataTable Gets the child DataTable to which the
UniqueConstraint belongs
UpdateRule Rule Gets or sets the Rule that indicates the action that
is to take place when a DataRow in the parent DataTable is updated See the DeleteRule property for the members of the Rule enumeration
The default is Cascade