Table of Contents

Class KeyComparer

Namespace
Microsoft.EntityFrameworkCore.Metadata
Assembly
Microsoft.EntityFrameworkCore.dll

An implementation of IComparer<T> and IEqualityComparer<T> to compare IReadOnlyKey instances.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

public sealed class KeyComparer : IEqualityComparer<IReadOnlyKey>, IComparer<IReadOnlyKey>
Inheritance
KeyComparer
Implements
Inherited Members

Remarks

See Implementation of database providers and extensions for more information and examples.

Fields

Instance

The singleton instance of the comparer to use.

public static readonly KeyComparer Instance

Field Value

KeyComparer

Methods

Compare(IReadOnlyKey?, IReadOnlyKey?)

Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

public int Compare(IReadOnlyKey? x, IReadOnlyKey? y)

Parameters

x IReadOnlyKey

The first object to compare.

y IReadOnlyKey

The second object to compare.

Returns

int

A negative number if 'x' is less than 'y'; a positive number if 'x' is greater than 'y'; zero otherwise.

Equals(IReadOnlyKey?, IReadOnlyKey?)

Determines whether the specified objects are equal.

public bool Equals(IReadOnlyKey? x, IReadOnlyKey? y)

Parameters

x IReadOnlyKey

The first object to compare.

y IReadOnlyKey

The second object to compare.

Returns

bool

true if the specified objects are equal; otherwise, false.

GetHashCode(IReadOnlyKey)

Returns a hash code for the specified object.

public int GetHashCode(IReadOnlyKey obj)

Parameters

obj IReadOnlyKey

The for which a hash code is to be returned.

Returns

int

A hash code for the specified object.