Skip to main content
Version: Preview (0.3.0-preview.205)

Class ValueObjectDapper

Namespace: AdCodicem.ValueObjects.Dapper
Assembly: AdCodicem.ValueObjects.Dapper.dll

Registers Dapper type handlers for value objects.

public static class ValueObjectDapper

Inheritance​

object ← ValueObjectDapper

Inherited Members​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks​

Dapper keeps its handlers in a process-wide table, so this is called once at start-up. Without it, every query touching a value object would need an explicit projection.

Methods​

AddValueObjectHandler<TSelf, TValue>()​

Registers a handler for one value object, such as a construction of a generic value object.

public static void AddValueObjectHandler<TSelf, TValue>() where TSelf : struct, IValueObject<TSelf, TValue>

Type Parameters​

TSelf

Value object type, Code<Order> for instance.

TValue

Underlying value type.

Remarks​

The handler is the one registers, for the value object and its nullable form, and a value object Dapper already has a handler for keeps it. Closed at compile time, it needs no dynamic code to be built; Dapper reflects over the handlers it is given, and the handler of a construction reads the column the construction declares from the registry, which describes the construction by reflection.

Exceptions​

NotSupportedException

TValue is or , which no ADO.NET provider carries.

AddValueObjectHandlers(params Assembly[])​

Registers a handler for every value object declared in the given assemblies.

[RequiresUnreferencedCode("Closes the generic type handler over each value object type.")]
[RequiresDynamicCode("Closes the generic type handler over each value object type.")]
public static void AddValueObjectHandlers(params Assembly[] assemblies)

Parameters​

assemblies Assembly[]

Assemblies declaring the value objects. When none is given, everything already registered is handled.

Remarks​

A value object Dapper already has a handler for keeps it, whoever registered it, so calling this again changes nothing and a handler of the application's own is not replaced. Which types are handled is read from Dapper's table rather than remembered here, so a call after registers everything again.

A value object over or gets no handler. No ADO.NET provider takes either as a parameter or returns one, so the column type, and the conversion to it, are the application's to choose, in a handler of its own.

A generic value object has no handler until its constructions are known, and Dapper looks a handler up by the exact type, ahead of any query: register each construction with .