Class ValueComparer<T>
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
favorStructuralComparisonsboolIf 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
equalsExpressionExpression<Func<T, T, bool>>The comparison expression.
hashCodeExpressionExpression<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
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
favorStructuralComparisonsboolIf 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
Returns
Equals(T?, T?)
Compares the two instances to determine if they are equal.
public virtual bool Equals(T? x, T? y)
Parameters
xTThe first instance.
yTThe second instance.
Returns
GetHashCode(object?)
Returns the hash code for the given instance.
public override int GetHashCode(object? obj)
Parameters
objobjectThe instance.
Returns
- int
The hash code.
GetHashCode(T?)
Returns the hash code for the given instance.
public virtual int GetHashCode(T? obj)
Parameters
objTThe instance.
Returns
- int
The hash code.