DataRelation.ChildKeyConstraint Свойство

Определение

Возвращает ForeignKeyConstraint для отношения.

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.

Примеры

В следующем примере задается UpdateRuleправило , DeleteRuleи AcceptReject для , связанного ForeignKeyConstraintDataRelationс .

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указывает , когда отношение добавляется в коллекцию связей.

Применяется к

См. также раздел