ChildKeyConstraint Property

DataRelation.ChildKeyConstraint Property


Gets the ForeignKeyConstraint for the relation.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public virtual ForeignKeyConstraint ChildKeyConstraint { get; }

Property Value

Type: System.Data.ForeignKeyConstraint

A ForeignKeyConstraint.

If no associated ForeignKeyConstraint exists for this relationship, it will be created automatically, and pointed to by the ChildKeyConstraint, when the relation is added to the collection of relations.

The following example sets the UpdateRule, DeleteRule, and AcceptReject rule for the ForeignKeyConstraint associated with the DataRelation.

Private Sub SetChildKeyConstraint(dataSet As DataSet)
   ' Set child and parent columns.
   Dim parentColumn As DataColumn = dataSet.Tables( _
   Dim childColumn As DataColumn = dataSet.Tables( _
   Dim relation As DataRelation = New DataRelation( _
       "SuppliersConstraint", parentColumn, childColumn)

   Dim foreignKey As ForeignKeyConstraint = _
   foreignKey.DeleteRule = Rule.SetNull
   foreignKey.UpdateRule = Rule.Cascade
   foreignKey.AcceptRejectRule = AcceptRejectRule.Cascade
End Sub

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft