EntityKey.Inequality(EntityKey, EntityKey) 运算符

定义

比较两个 EntityKey 对象。Compares two EntityKey objects.

public:
 static bool operator !=(System::Data::EntityKey ^ key1, System::Data::EntityKey ^ key2);
public static bool operator != (System.Data.EntityKey key1, System.Data.EntityKey key2);
static member op_Inequality : System.Data.EntityKey * System.Data.EntityKey -> bool
Public Shared Operator != (key1 As EntityKey, key2 As EntityKey) As Boolean

参数

key1
EntityKey

要比较的 EntityKeyA EntityKey to compare.

key2
EntityKey

要比较的 EntityKeyA EntityKey to compare.

返回

Boolean

如果 key1key2 值不相等,则为 true;否则为 falsetrue if the key1 and key2 values are not equal; otherwise, false.

注解

临时键与永久键的比较语义不同:Temporary keys have different comparison semantics than permanent keys:

  • 临时键使用引用相等性。Temporary keys use reference equality. 也就是说,对同一个临时 EntityKey 实例的两个引用是相等的,但其他 EntityKey 实例不相等。That is, two references to the exact same temporary EntityKey instance are equal but no other EntityKey instances are equal.

  • 永久键根据所包含的键属性的值和 EntitySet 来确定相等性。Permanent keys determine equality based on the values of the contained key properties and the EntitySet. 也就是说,对于两个独立的 EntityKey 实例,如果它们的实体集相同并且键值相等,则这两个实例相等。That is, you can have two separate EntityKey instances that are equal if their entity sets are the same and their key values are equal.

此外,临时键没有 EntitySet 或键值,但常规键有。In addition, temporary keys have no EntitySet or key values, but regular keys do.

此运算符的等效方法为 EntityKey.Equals(EntityKey)The equivalent method for this operator is EntityKey.Equals(EntityKey).

适用于