Interface IEventUpcaster
- Namespace
- Stratara.Abstractions.EventSourcing
- Assembly
- Stratara.Abstractions.dll
Transforms a persisted event's raw JSON payload from an older on-disk schema into the shape the current event record expects, applied on read before the payload is deserialized into a runtime type. This is the framework's event upcasting hook: it lets an event's structure evolve (renamed / added / defaulted / moved fields, or a renamed event type) without rewriting the immutable events already in the store.
public interface IEventUpcaster
- Extension Methods
Remarks
An upcaster is matched by SourceEventTypeName against the type name persisted in the
event row (compared in the version-independent form — assembly Version / Culture /
PublicKeyToken segments are ignored). When it matches, Upcast(JsonNode) rewrites the JSON
and the payload's effective type name becomes TargetEventTypeName. Upcasters chain:
register one per schema hop (v1→v2, v2→v3, …) and the pipeline applies them in sequence until no
further upcaster matches, then resolves TargetEventTypeName and deserializes.
Because upcasting runs on the payload as persisted, values of fields marked
[EncryptData] are still ciphertext at this point — an upcaster can restructure them (rename /
move the field) but cannot read or produce their plaintext. Snapshots are not upcasted; a change to
an aggregate's shape should invalidate or rebuild its snapshots.
Properties
SourceEventTypeName
The persisted event type name this upcaster reads from, in version-independent assembly-qualified
form (for example "MyApp.Events.OrderPlacedV1, MyApp"). Matched against the name stored in
the event row; a renamed or since-removed source type is fine because the source type is never
resolved — only TargetEventTypeName is.
string SourceEventTypeName { get; }
Property Value
TargetEventTypeName
The event type name the payload carries after this upcaster runs, in version-independent assembly-qualified form. Equal to SourceEventTypeName for an in-place shape change, or a different registered type name when the event was renamed. Must resolve through the trusted-type resolver once the chain completes.
string TargetEventTypeName { get; }
Property Value
Methods
Upcast(JsonNode)
Rewrites the raw event payload from the source schema to the target schema.
JsonNode Upcast(JsonNode payload)
Parameters
payloadJsonNodeThe persisted payload parsed as a mutable JSON node.
Returns
- JsonNode
The upcasted payload — the same node mutated in place, or a new node.