ForeignKeyConstraint.Equals(Object) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá hodnotu určující, zda aktuální ForeignKeyConstraint je identický se zadaným objektem.
public:
override bool Equals(System::Object ^ key);
public override bool Equals(object? key);
public override bool Equals(object key);
override this.Equals : obj -> bool
Public Overrides Function Equals (key As Object) As Boolean
Parametry
- key
- Object
Objekt, ke kterému se tento ForeignKeyConstraint objekt porovnává. Dvě ForeignKeyConstraint jsou stejné, pokud omezují stejné sloupce.
Návraty
true, jsou-li objekty identické; v opačném případě . false
Příklady
Následující příklad vytvoří novou ForeignKeyConstraint a zkontroluje ji proti ostatním členům kolekce pomocí Equals metody před přidáním do objektu ConstraintCollection.
private void CreateConstraint(DataSet dataSet)
{
// Create the ForignKeyConstraint with two DataColumn objects.
DataColumn parentCol = dataSet.Tables["Customers"].Columns["id"];
DataColumn childCol = dataSet.Tables["Orders"].Columns["OrderID"];
ForeignKeyConstraint fkeyConstraint =
new ForeignKeyConstraint("fkConstraint", parentCol, childCol);
// Test against existing members using the Equals method.
foreach(ForeignKeyConstraint testConstraint in
dataSet.Tables["Orders"].Constraints)
{
if(fkeyConstraint.Equals(testConstraint)){
Console.WriteLine("Identical ForeignKeyConstraint!");
// Insert code to delete the duplicate object,
// or stop the procedure.
}
}
}
Private Sub CreateConstraint(dataSet As DataSet)
' Create the ForignKeyConstraint with two DataColumn objects.
Dim parentCol As DataColumn = _
dataSet.Tables("Customers").Columns("id")
Dim childCol As DataColumn = _
dataSet.Tables("Orders").Columns("OrderID")
Dim fkeyConstraint As _
New ForeignKeyConstraint("fkConstraint", parentCol, childCol)
' Test against existing members using the Equals method.
Dim testConstraint As ForeignKeyConstraint
For Each testConstraint In dataSet.Tables("Orders").Constraints
If fkeyConstraint.Equals(testConstraint) Then
Console.WriteLine("Identical ForeignKeyConstraint!")
' Insert code to delete the duplicate object,
' or stop the procedure.
End If
Next testConstraint
End Sub