Class ValueObjectConventionExtensions
Namespace: AdCodicem.ValueObjects.EntityFrameworkCore
Assembly: AdCodicem.ValueObjects.EntityFrameworkCore.dll
Maps value objects onto their underlying database types.
public static class ValueObjectConventionExtensions
Inheritance
object ← ValueObjectConventionExtensions
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Methods
ConfigureValueObjects(ModelConfigurationBuilder, params Assembly[])
Maps every value object declared in the given assemblies to its underlying column type.
public static ModelConfigurationBuilder ConfigureValueObjects(this ModelConfigurationBuilder builder, params Assembly[] assemblies)
Parameters
builder ModelConfigurationBuilder
Model configuration builder, from DbContext.ConfigureConventions.
assemblies Assembly[]
Assemblies declaring the value objects. When none is given, everything already registered is mapped, which is enough as soon as the entity assembly has been loaded.
Returns
The same builder, so calls can be chained.
Remarks
A value object declaring a maximum length also sizes its column, so an IBAN lands in varchar(34)
rather than an unbounded column — the rule is stated once, on the type, and the schema follows.
This runs once, while the model is built. Nothing here happens per query or per row.
ConfigureValueObjects(ModelConfigurationBuilder, bool, params Assembly[])
Maps every value object declared in the given assemblies, optionally re-validating on read.
public static ModelConfigurationBuilder ConfigureValueObjects(this ModelConfigurationBuilder builder, bool strict, params Assembly[] assemblies)
Parameters
builder ModelConfigurationBuilder
Model configuration builder, from DbContext.ConfigureConventions.
strict bool
When true, values read from the database are normalized and validated again. Use it for tables another system also writes to; it costs a validation per materialized value.
assemblies Assembly[]
Assemblies declaring the value objects.
Returns
The same builder, so calls can be chained.
HasValueObjectConversion<TSelf, TValue>(PropertyBuilder<TSelf>, bool)
Maps a single property to the underlying value of its value object.
public static PropertyBuilder<TSelf> HasValueObjectConversion<TSelf, TValue>(this PropertyBuilder<TSelf> builder, bool strict = false) where TSelf : struct, IValueObject<TSelf, TValue>
Parameters
builder PropertyBuilder<TSelf>
Property builder.
strict bool
When true, values read from the database are validated again.
Returns
PropertyBuilder<TSelf>
The same builder, so calls can be chained.
Type Parameters
TSelf
Value object type.
TValue
Underlying value type.
Remarks
Use this for a property that needs to depart from the convention; otherwise prefer the convention.