Class ProjectionBuilderFor<TReadModel>
- Namespace
- Cratis.Chronicle.Projections
- Assembly
- Cratis.Chronicle.dll
Represents an implementation of IProjectionBuilderFor<TReadModel>.
public class ProjectionBuilderFor<TReadModel> : ProjectionBuilder<TReadModel, IProjectionBuilderFor<TReadModel>>, IProjectionBuilderFor<TReadModel>, IProjectionBuilder<TReadModel, IProjectionBuilderFor<TReadModel>>
Type Parameters
TReadModelType of read model.
- Inheritance
-
ProjectionBuilder<TReadModel, IProjectionBuilderFor<TReadModel>>ProjectionBuilderFor<TReadModel>
- Implements
-
IProjectionBuilderFor<TReadModel>IProjectionBuilder<TReadModel, IProjectionBuilderFor<TReadModel>>
- Inherited Members
- Extension Methods
Constructors
ProjectionBuilderFor(ProjectionId, Type, INamingPolicy, IEventTypes, JsonSerializerOptions)
Initializes a new instance of the ProjectionBuilderFor<TReadModel> class.
public ProjectionBuilderFor(ProjectionId identifier, Type projectionType, INamingPolicy namingPolicy, IEventTypes eventTypes, JsonSerializerOptions jsonSerializerOptions)
Parameters
identifierProjectionIdThe unique identifier for the projection.
projectionTypeTypeThe type of the projection.
namingPolicyINamingPolicyThe INamingPolicy to use for converting names during serialization.
eventTypesIEventTypesIEventTypes for providing event type information.
jsonSerializerOptionsJsonSerializerOptionsThe JsonSerializerOptions to use for any JSON serialization.
Methods
ContainerName(string)
Names the model container - typically used by storage as name of storage unit (collection, table, etc.).
public IProjectionBuilderFor<TReadModel> ContainerName(string containerName)
Parameters
containerNamestringContainer name of the read model.
Returns
- IProjectionBuilderFor<TReadModel>
Builder continuation.
Remarks
Overrides the container name the naming policy would otherwise give the read model. The identifier of the read model is not affected. Every projection of the same read model must agree on the container name.
EntersOn<TEvent>()
Declares the event that activates this variant.
public IProjectionBuilderFor<TReadModel> EntersOn<TEvent>()
Returns
- IProjectionBuilderFor<TReadModel>
Builder continuation.
Type Parameters
TEventType of event that activates this variant.
Remarks
Only for a projection that also declares VariantOf<TIdentity>(Expression<Func<TReadModel, object?>>). The event keeps its ordinary
create-or-update behavior; mapping its properties is still done with the usual
From call.
FromEventSequence(EventSequenceId)
Specifies the EventSequenceId to use as source.
public IProjectionBuilderFor<TReadModel> FromEventSequence(EventSequenceId eventSequenceId)
Parameters
eventSequenceIdEventSequenceIdEventSequenceId to use.
Returns
- IProjectionBuilderFor<TReadModel>
Builder continuation.
NotRewindable()
Set the projection to not be rewindable - its a moving forward only projection.
public IProjectionBuilderFor<TReadModel> NotRewindable()
Returns
- IProjectionBuilderFor<TReadModel>
Builder continuation.
Passive()
Set the projection not be active, meaning that it won't actively observe.
public IProjectionBuilderFor<TReadModel> Passive()
Returns
- IProjectionBuilderFor<TReadModel>
Builder continuation.
VariantOf<TIdentity>(Expression<Func<TReadModel, object?>>)
Declares this projection as one of several mutually exclusive representations of the same logical entity.
public IProjectionBuilderFor<TReadModel> VariantOf<TIdentity>(Expression<Func<TReadModel, object?>> keyAccessor)
Parameters
keyAccessorExpression<Func<TReadModel, object>>Accessor for this read model's own key, used to correlate an event back to an already-active instance.
Returns
- IProjectionBuilderFor<TReadModel>
Builder continuation.
Type Parameters
TIdentityThe type anchoring the logical identity the variants share. It needs no read model and no common base type with the variants.
Remarks
Every projection declaring the same TIdentity forms a group. Entering one variant
removes the entity from every other variant in that group. Only the events named with
EntersOn<TEvent>() may create this variant; every other event it projects from becomes an
update-only mapping that can bring an active instance up to date but never create or resurrect one.