Class NullableValueObjectComparer<TSelf>
Namespace: AdCodicem.ValueObjects.EntityFrameworkCore
Assembly: AdCodicem.ValueObjects.EntityFrameworkCore.dll
Compares optional value objects using their own equality rather than the underlying value's, as
public sealed class NullableValueObjectComparer<TSelf> : ValueComparer<TSelf?>, IEqualityComparer, IEqualityComparer<object>, IEqualityComparer<TSelf?> where TSelf : struct, IEquatable<TSelf>
Type Parameters
TSelf
Value object type.
Inheritance
object ← ValueComparer ← ValueComparer<TSelf?> ← NullableValueObjectComparer<TSelf>
Implements
IEqualityComparer, IEqualityComparer<object>, IEqualityComparer<TSelf?>
Inherited Members
ValueComparer<TSelf?>.Equals(object?, object?), ValueComparer<TSelf?>.GetHashCode(object?), ValueComparer<TSelf?>.Equals(TSelf?, TSelf?), ValueComparer<TSelf?>.GetHashCode(TSelf?), ValueComparer<TSelf?>.Snapshot(object?), ValueComparer<TSelf?>.Snapshot(TSelf?), ValueComparer<TSelf?>.ObjectEqualsExpression, ValueComparer<TSelf?>.Type, ValueComparer<TSelf?>.EqualsExpression, ValueComparer<TSelf?>.HashCodeExpression, ValueComparer<TSelf?>.SnapshotExpression, ValueComparer.GetGenericSnapshotMethod(Type), ValueComparer.Equals(object?, object?), ValueComparer.GetHashCode(object?), ValueComparer.Snapshot(object?), ValueComparer.ExtractEqualsBody(Expression, Expression), ValueComparer.ExtractHashCodeBody(Expression), ValueComparer.ExtractSnapshotBody(Expression), ValueComparer.Add(HashCode, int), ValueComparer.CreateDefault(Type, bool), ValueComparer.CreateDefault<T>(bool), ValueComparer.Type, ValueComparer.EqualsExpression, ValueComparer.ObjectEqualsExpression, ValueComparer.HashCodeExpression, ValueComparer.SnapshotExpression, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The conventions give it to every property holding a TSelf?. Left to itself, Entity Framework Core would
wrap dotnet ef dbcontext optimize writes for that wrapping does not compile: it names the comparer where the
wrapper takes the value type. A comparer of the nullable type itself is written as it stands.
Two absent values are equal, an absent value equals no present one, and two present ones are equal when the value object says they are. A value object is immutable, so the snapshot is the value itself.
TSelf carries the annotation
Constructors
NullableValueObjectComparer()
Initializes a new instance of the
public NullableValueObjectComparer()