UniqueConstraint.Equals(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将此约束与第二个约束比较以确定两个约束是否相同。
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
注解
如果两个约束约束相同的列,则它们相等。