ForeignKeyConstraint.Equals(Object) Método

Definición

Obtiene un valor que indica si la clase ForeignKeyConstraint actual es idéntica al objeto especificado.

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

Parámetros

key
Object

Objeto con el que se compara este ForeignKeyConstraint. Dos ForeignKeyConstraint son iguales si restringen las mismas columnas.

Devoluciones

true si los objetos son idénticos; en caso contrario, false.

Ejemplos

En el ejemplo siguiente se crea un nuevo ForeignKeyConstraint y se comprueba con otros miembros de la colección con el Equals método antes de agregarlo 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

Se aplica a