DataRelation.ChildKeyConstraint Свойство
Определение
Возвращает ForeignKeyConstraint для отношения.Gets 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
.A ForeignKeyConstraint
.
Примеры
В следующем примере задается UpdateRule
DeleteRule
правило, и AcceptReject
для, ForeignKeyConstraint
связанного с DataRelation
.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( _
"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.