다음을 통해 공유


ForeignKeyConstraint.Equals(Object) 메서드

정의

현재 ForeignKeyConstraint가 지정된 개체와 같은지 여부를 나타내는 값을 가져옵니다.

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

매개 변수

key
Object

ForeignKeyConstraint와 비교할 개체입니다. 동일한 열을 제한하는 두 개의 ForeignKeyConstraint는 동일합니다.

반환

개체가 동일하면 true를 반환하고, 그렇지 않으면 false를 반환합니다.

예제

다음 예제에서는 새 ForeignKeyConstraint 를 만들고 에 추가ConstraintCollection하기 전에 메서드를 Equals 사용하여 다른 컬렉션 멤버에 대해 확인합니다.

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

적용 대상