UniqueConstraint.Equals(Object) 方法

定义

将此约束与第二个约束比较以确定两个约束是否相同。

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

参数

key2
Object

UniqueConstraint 将与之比较的对象。

返回

如果约束相同,则为 true;否则为 false

示例

以下示例比较两个 UniqueConstraint 对象。

Private Sub CompareConstraints()
    Dim constraintCustomerOrders As UniqueConstraint
    Dim constraintOrderDetails As UniqueConstraint
    Dim relationCustomerOrders As DataRelation
    Dim relationOrderDetails As DataRelation

    ' Get a DataRelation from a DataSet.
    relationCustomerOrders = DataSet1.Relations("CustomerOrders")

    '  Get a constraint.
    constraintCustomerOrders = relationCustomerOrders.ParentKeyConstraint

    ' Get a second relation and constraint.
    relationOrderDetails = DataSet1.Relations("OrderDetails")
    constraintOrderDetails = relationOrderDetails.ParentKeyConstraint

    ' Compare the two.
    Console.WriteLine( _
        constraintCustomerOrders.Equals(constraintOrderDetails).ToString())
 End Sub

注解

如果两个约束约束相同的列,则它们相等。

适用于

另请参阅