DataRelation.ChildKeyConstraint 属性

定义

获取关系的 ForeignKeyConstraintGets the ForeignKeyConstraint for the relation.

public:
 virtual property System::Data::ForeignKeyConstraint ^ ChildKeyConstraint { System::Data::ForeignKeyConstraint ^ get(); };
public virtual System.Data.ForeignKeyConstraint? ChildKeyConstraint { get; }
public virtual System.Data.ForeignKeyConstraint ChildKeyConstraint { get; }
member this.ChildKeyConstraint : System.Data.ForeignKeyConstraint
Public Overridable ReadOnly Property ChildKeyConstraint As ForeignKeyConstraint

属性值

ForeignKeyConstraint

ForeignKeyConstraintA ForeignKeyConstraint.

示例

下面的示例设置 UpdateRule DeleteRule AcceptReject 与关联的、和规则 ForeignKeyConstraint DataRelationThe 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( _
       "Suppliers").Columns("SupplierID")
   Dim childColumn As DataColumn = dataSet.Tables( _
       "Products").Columns("SupplierID")
   Dim relation As New DataRelation( _
       "SuppliersConstraint", parentColumn, childColumn)
   dataSet.Relations.Add(relation)

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

注解

如果 ForeignKeyConstraint 此关系不存在关联的,则 ChildKeyConstraint 当关系添加到关系的集合中时,将自动创建它并将其指向。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.

适用于

另请参阅