ForeignKeyConstraint.Equals(Object) Methode

Definition

Ruft einen Wert ab, der angibt, ob der aktuelle ForeignKeyConstraint mit dem angegebenen Objekt identisch istGets a value indicating whether the current ForeignKeyConstraint is identical to the specified object.

public:
 override bool Equals(System::Object ^ key);
public override bool Equals (object key);
override this.Equals : obj -> bool
Public Overrides Function Equals (key As Object) As Boolean

Parameter

key
Object

Das Objekt, mit dem diese ForeignKeyConstraint verglichen wird.The object to which this ForeignKeyConstraint is compared. Zwei ForeignKeyConstraint sind gleich, wenn sie dieselben Spalten einschränken.Two ForeignKeyConstraint are equal if they constrain the same columns.

Gibt zurück

true, wenn die Objekte identisch sind, andernfalls false.true, if the objects are identical; otherwise, false.

Beispiele

Im folgenden Beispiel wird ein neues ForeignKeyConstraint -Element erstellt und mit der Equals -Methode auf andere Auflistungs Elemente überprüft ConstraintCollection, bevor es einem hinzugefügt wird.The following example creates a new ForeignKeyConstraint and checks it against other collection members with the Equals method before adding it to a 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

Gilt für: