ForeignKeyConstraint.Equals(Object) ForeignKeyConstraint.Equals(Object) ForeignKeyConstraint.Equals(Object) ForeignKeyConstraint.Equals(Object) Method

Definizione

Ottiene un valore che indica se l'elemento ForeignKeyConstraint corrente è identico all'oggetto specificato.Gets 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

Parametri

key
Object Object Object Object

Oggetto con il quale viene confrontato l'oggetto ForeignKeyConstraint.The object to which this ForeignKeyConstraint is compared. Due oggetti ForeignKeyConstraint risultano uguali se applicano vincoli alle stesse colonne.Two ForeignKeyConstraint are equal if they constrain the same columns.

Restituisce

true se gli oggetti sono identici; in caso contrario, false .true, if the objects are identical; otherwise, false.

Esempi

Nell'esempio seguente viene creato un ForeignKeyConstraint nuovo oggetto che viene verificato rispetto ad altri membri Equals della raccolta con il metodo prima ConstraintCollectiondi aggiungerlo a un.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

Si applica a