Table of Contents

Class ValueComparer

Namespace
LinqToDB.Internal.Common
Assembly
linq2db.dll

This is internal API and is not intended for use by Linq To DB applications. It may change or be removed without further notice.

public abstract class ValueComparer : IEqualityComparer, IEqualityComparer<object>
Inheritance
ValueComparer
Implements
Derived
Inherited Members
Extension Methods

Constructors

ValueComparer(LambdaExpression, LambdaExpression)

Creates a new ValueComparer with the given comparison.

protected ValueComparer(LambdaExpression equalsExpression, LambdaExpression hashCodeExpression)

Parameters

equalsExpression LambdaExpression

The comparison expression.

hashCodeExpression LambdaExpression

The associated hash code generator.

Properties

EqualsExpression

The comparison expression.

public virtual LambdaExpression EqualsExpression { get; }

Property Value

LambdaExpression

HashCodeExpression

The hash code expression.

public virtual LambdaExpression HashCodeExpression { get; }

Property Value

LambdaExpression

Type

The type.

public abstract Type Type { get; }

Property Value

Type

Methods

CreateDefault(Type, bool)

Creates a default ValueComparer<T> for the given type.

public static ValueComparer CreateDefault(Type type, bool favorStructuralComparisons)

Parameters

type Type

The type.

favorStructuralComparisons bool

If true, then IStructuralEquatable will be used if the type implements it. This is usually used when byte arrays act as keys.

Returns

ValueComparer

The ValueComparer<T>.

Equals(object?, object?)

Compares the two instances to determine if they are equal.

public abstract bool Equals(object? x, object? y)

Parameters

x object

The first instance.

y object

The second instance.

Returns

bool

true if they are equal; false otherwise.

ExtractEqualsBody(Expression, Expression)

Takes EqualsExpression and replaces the two parameters with the given expressions, returning the transformed body.

public virtual Expression ExtractEqualsBody(Expression leftExpression, Expression rightExpression)

Parameters

leftExpression Expression

The new left expression.

rightExpression Expression

The new right expression.

Returns

Expression

The body of the lambda with left and right parameters replaced.

GetDefaultValueComparer(Type, bool)

public static ValueComparer GetDefaultValueComparer(Type type, bool favorStructuralComparisons)

Parameters

type Type
favorStructuralComparisons bool

Returns

ValueComparer

GetDefaultValueComparer<T>(bool)

public static ValueComparer<T> GetDefaultValueComparer<T>(bool favorStructuralComparisons)

Parameters

favorStructuralComparisons bool

Returns

ValueComparer<T>

Type Parameters

T

GetHashCode(object?)

Returns the hash code for the given instance.

public abstract int GetHashCode(object? obj)

Parameters

obj object

The instance.

Returns

int

The hash code.