Table of Contents

Interface IProjection<TKey>

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

Represents a read model projection that is built from domain events.

public interface IProjection<out TKey> where TKey : notnull

Type Parameters

TKey

The type of the key that uniquely identifies this projection.

Extension Methods

Remarks

Projections are read models that are derived from event streams and are used to support query scenarios in CQRS and Event Sourcing architectures.

Properties

Id

Gets the unique identifier for this projection.

TKey Id { get; }

Property Value

TKey

The unique projection identifier.

LastModified

Gets the timestamp when this projection was last updated.

DateTimeOffset LastModified { get; }

Property Value

DateTimeOffset

The timestamp of the last update.

Version

Gets the version this projection's state reflects.

long Version { get; }

Property Value

long

The projection version number.

Remarks

ASSIGN IT; DO NOT INCREMENT IT. Version++ counts how many times a fold has run against this row, which is a different quantity from the one this property names. The two agree only when the row has folded every version from the first, contiguously, exactly once — so a projection registered later and filled from a mid-stream position, or a row re-folded by a rebuild or a recovery, reports a version its stream never had.

WHAT TO ASSIGN follows from what the projection is keyed by. A read model of ONE aggregate assigns the committed version of the event it is folding, supplied to a DI-resolved handler as ProjectionHandlerContext.CommittedVersion. A projection keyed across SEVERAL streams has no single aggregate version to name, so it assigns the event's global stream position instead: monotonic, and meaningful for a row that many streams write to.

This value is yours — the framework never reads it. Suppressing an event a row has already folded is done against a separate position the store owns, which is not this property and is not present on the document you read back. So a wrong value here does not weaken that suppression; it misreports the row to whoever queries it, which is the harm to avoid.