Bagikan melalui


DataRelation.ChildKeyConstraint Properti

Definisi

ForeignKeyConstraint Mendapatkan untuk relasi.

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

Nilai Properti

ForeignKeyConstraint.

Contoh

Contoh berikut menetapkan UpdateRuleaturan , DeleteRule, dan AcceptReject untuk yang ForeignKeyConstraint terkait dengan 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

Keterangan

Jika tidak ada yang terkait ForeignKeyConstraint untuk hubungan ini, itu akan dibuat secara otomatis, dan ditujukkan oleh ChildKeyConstraint, ketika relasi ditambahkan ke pengumpulan hubungan.

Berlaku untuk

Lihat juga