DataRelation.ChildKeyConstraint 属性
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取关系的 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
与 DataRelation
关联的 设置 、 DeleteRule
和 AcceptReject
规则ForeignKeyConstraint
。
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
指向该关系。