Table of Contents

Class ValueComparer<T>

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 class ValueComparer<T> : ValueComparer, IEqualityComparer, IEqualityComparer<object>, IEqualityComparer<T>

Type Parameters

T
Inheritance
ValueComparer<T>
Implements
Inherited Members
Extension Methods

Constructors

ValueComparer(bool)

Creates a new ValueComparer<T> with a default comparison expression and a shallow copy for the snapshot.

public ValueComparer(bool favorStructuralComparisons)

Parameters

favorStructuralComparisons bool

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

ValueComparer(Expression<Func<T, T, bool>>, Expression<Func<T, int>>)

Creates a new ValueComparer<T> with the given comparison expression. A shallow copy will be used for the snapshot.

public ValueComparer(Expression<Func<T, T, bool>> equalsExpression, Expression<Func<T, int>> hashCodeExpression)

Parameters

equalsExpression Expression<Func<T, T, bool>>

The comparison expression.

hashCodeExpression Expression<Func<T, int>>

The associated hash code generator.

Properties

EqualsExpression

The comparison expression.

public virtual Expression<Func<T?, T?, bool>> EqualsExpression { get; }

Property Value

Expression<Func<T, T, bool>>

HashCodeExpression

The hash code expression.

public virtual Expression<Func<T?, int>> HashCodeExpression { get; }

Property Value

Expression<Func<T, int>>

Type

The type.

public override Type Type { get; }

Property Value

Type

Methods

CreateDefaultEqualsExpression()

Creates an expression for equality.

protected static Expression<Func<T, T, bool>> CreateDefaultEqualsExpression()

Returns

Expression<Func<T, T, bool>>

The equality expression.

CreateDefaultHashCodeExpression(bool)

Creates an expression for generating a hash code.

protected static Expression<Func<T, int>> CreateDefaultHashCodeExpression(bool favorStructuralComparisons)

Parameters

favorStructuralComparisons bool

If true, then IStructuralEquatable is used if the type implements it.

Returns

Expression<Func<T, int>>

The hash code expression.

Equals(object?, object?)

Compares the two instances to determine if they are equal.

public override 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.

Equals(T?, T?)

Compares the two instances to determine if they are equal.

public virtual bool Equals(T? x, T? y)

Parameters

x T

The first instance.

y T

The second instance.

Returns

bool

true if they are equal; false otherwise.

GetHashCode(object?)

Returns the hash code for the given instance.

public override int GetHashCode(object? obj)

Parameters

obj object

The instance.

Returns

int

The hash code.

GetHashCode(T?)

Returns the hash code for the given instance.

public virtual int GetHashCode(T? obj)

Parameters

obj T

The instance.

Returns

int

The hash code.