Table of Contents

Class ProjectionSerializationDefaults

Namespace
Excalibur.Data
Assembly
Excalibur.Data.Abstractions.dll

Canonical JsonSerializerOptions for projection read-model persistence.

public static class ProjectionSerializationDefaults
Inheritance
ProjectionSerializationDefaults
Inherited Members

Remarks

A projection is a queryable read-model, not an event. This contract is deliberately distinct from the event-payload serializer: it uses camelCase property naming and omits null properties for a compact, consumer-facing document shape, but it preserves the numeric representation of enums (no string-enum converter). Read-model JSON is filtered through SQL / search predicates where an enum-as-string would break range and equality queries, so numeric enums are part of the read-model contract rather than an incidental default.

Every projection store sources its options from this single factory so the persisted document shape stays consistent across providers, while still allowing a consumer to supply their own JsonSerializerOptions where they need full control.

Methods

CreateReadModelOptions()

Creates a new mutable JsonSerializerOptions instance carrying the projection read-model contract: camelCase naming, null-property omission, and numeric enum values.

public static JsonSerializerOptions CreateReadModelOptions()

Returns

JsonSerializerOptions

A fresh options instance the caller owns and may further customize.

CreateReadModelTypeInfo<TProjection>(JsonSerializerOptions, JsonTypeInfo<TProjection>)

Derives generated read metadata that reads back exactly the document shape writeOptions produced, using the resolver carried by generatedTypeInfo so no reflection is introduced.

public static JsonTypeInfo<TProjection> CreateReadModelTypeInfo<TProjection>(JsonSerializerOptions writeOptions, JsonTypeInfo<TProjection> generatedTypeInfo) where TProjection : class

Parameters

writeOptions JsonSerializerOptions

The options the store persists with. These govern the wire contract.

generatedTypeInfo JsonTypeInfo<TProjection>

Generated metadata supplying the trim-safe resolver for TProjection.

Returns

JsonTypeInfo<TProjection>

Metadata bound to the persisted document shape.

Type Parameters

TProjection

The read schema.

Remarks

The persisted shape is the store's, not the caller's. Generated metadata obtained from a JsonSerializerContext that declares a different naming policy, or omits a converter the write path applied, describes a different document and would read defaults or wrong values with no error. Only the resolver is taken from the caller; every option that shapes the wire contract comes from the write path.

Exceptions

NotSupportedException

The supplied metadata carries no resolver, or its resolver does not describe TProjection.