ValueComparer Class

Definition

Specifies custom value snapshotting and comparison for CLR types that cannot be compared with Equals(Object, Object) and/or need a deep/structural copy when taking a snapshot. For example, arrays of primitive types will require both if mutation is to be detected.

public abstract class ValueComparer : System.Collections.IEqualityComparer
public abstract class ValueComparer : System.Collections.Generic.IEqualityComparer<object>, System.Collections.IEqualityComparer
type ValueComparer = class
    interface IEqualityComparer
type ValueComparer = class
    interface IEqualityComparer
    interface IEqualityComparer<obj>
Public MustInherit Class ValueComparer
Implements IEqualityComparer
Public MustInherit Class ValueComparer
Implements IEqualityComparer, IEqualityComparer(Of Object)
Inheritance
ValueComparer
Derived
Implements

Remarks

Snapshotting is the process of creating a copy of the value into a snapshot so it can later be compared to determine if it has changed. For some types, such as collections, this needs to be a deep copy of the collection rather than just a shallow copy of the reference.

See EF Core value comparers for more information and examples.

Constructors

ValueComparer(LambdaExpression, LambdaExpression, LambdaExpression)

Creates a new ValueComparer with the given comparison and snapshotting expressions.

Fields

BoolIdentity

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

HashCodeAddMethod

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

ToHashCodeMethod

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

Properties

EqualsExpression

The comparison expression.

HashCodeExpression

The hash code expression.

SnapshotExpression

The snapshot expression.

Type

The type.

Methods

Add(HashCode, Int32)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

CreateDefault(Type, Boolean)

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

CreateDefault<T>(Boolean)

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

Equals(Object, Object)

Compares the two instances to determine if they are equal.

ExtractEqualsBody(Expression, Expression)

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

ExtractHashCodeBody(Expression)

Takes the HashCodeExpression and replaces the parameter with the given expression, returning the transformed body.

ExtractSnapshotBody(Expression)

Takes the SnapshotExpression and replaces the parameter with the given expression, returning the transformed body.

GetHashCode(Object)

Returns the hash code for the given instance.

Snapshot(Object)

Creates a snapshot of the given instance.

Extension Methods

IsDefault(ValueComparer)

Returns true if the given ValueComparer is a default EF Core implementation.

Applies to