Class NullableValueObjectConverter<TSelf, TValue>
Namespace: AdCodicem.ValueObjects.EntityFrameworkCore
Assembly: AdCodicem.ValueObjects.EntityFrameworkCore.dll
Stores an optional value object over a value type as its bare underlying value, and a value it rejects as
NULL.
[SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "A compiled model calls the conversions on the converter type it was built from.")]
public sealed class NullableValueObjectConverter<TSelf, TValue> : ValueConverter<TSelf?, TValue?> where TSelf : struct, IValueObject<TSelf, TValue> where TValue : struct
Type Parameters
TSelf
Value object type.
TValue
Underlying value type.
Inheritance
object ← ValueConverter ← ValueConverter<TSelf?, TValue?> ← NullableValueObjectConverter<TSelf, TValue>
Inherited Members
ValueConverter<TSelf?, TValue?>.ConvertToProvider, ValueConverter<TSelf?, TValue?>.ConvertFromProvider, ValueConverter<TSelf?, TValue?>.ConvertToProviderTyped, ValueConverter<TSelf?, TValue?>.ConvertFromProviderTyped, ValueConverter<TSelf?, TValue?>.ConvertToProviderExpression, ValueConverter<TSelf?, TValue?>.ConvertFromProviderExpression, ValueConverter<TSelf?, TValue?>.ModelClrType, ValueConverter<TSelf?, TValue?>.ProviderClrType, ValueConverter<TSelf?, TValue?>.ConstructorExpression, ValueConverter.ComposeWith(ValueConverter?), ValueConverter.ConvertToProvider, ValueConverter.ConvertFromProvider, ValueConverter.ConvertToProviderExpression, ValueConverter.ConvertFromProviderExpression, ValueConverter.ModelClrType, ValueConverter.ProviderClrType, ValueConverter.MappingHints, ValueConverter.ConvertsNulls, ValueConverter.ConstructorExpression, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The convention maps a TSelf? property through it. Entity Framework Core answers a null itself, in both
directions; the converter sees a value object, which it stores as default(TSelf) can hold: the
column takes a NULL, so that is what it stores, rather than a value every later read would trust. Over a
value type, a constructed zero equals the default too, and validation tells a valid zero, which is stored, from a
refused one.
Reading uses the trusted factory, as
Constructors
NullableValueObjectConverter()
Initializes a new instance of the
public NullableValueObjectConverter()