Interface IProjectionBuilder<TReadModel, TBuilder>

Namespace
Cratis.Chronicle.Projections
Assembly
Cratis.Chronicle.dll

Defines the based builder for building out projections.

public interface IProjectionBuilder<TReadModel, TBuilder> where TBuilder : class

Type Parameters

TReadModel

Type of read model.

TBuilder

Type of actual builder.

Extension Methods

Methods

AutoMap()

Automatically map event properties to model properties on the events added.

IProjectionBuilder<TReadModel, TBuilder> AutoMap()

Returns

IProjectionBuilder<TReadModel, TBuilder>

Builder continuation.

Remarks

AutoMap is enabled by default. This method is for explicitly enabling it if needed.

Children<TChildModel>(Expression<Func<TReadModel, IEnumerable<TChildModel>>>, Action<IChildrenBuilder<TReadModel, TChildModel>>)

Start building the children projection for a specific child model.

TBuilder Children<TChildModel>(Expression<Func<TReadModel, IEnumerable<TChildModel>>> targetProperty, Action<IChildrenBuilder<TReadModel, TChildModel>> builderCallback)

Parameters

targetProperty Expression<Func<TReadModel, IEnumerable<TChildModel>>>

Expression for expressing the target property.

builderCallback Action<IChildrenBuilder<TReadModel, TChildModel>>

Builder callback.

Returns

TBuilder

Builder continuation.

Type Parameters

TChildModel

Type of nested child model.

FromAll(Action<IFromAllBuilder<TReadModel>>)

Start building property expressions that apply to all event types in the system. When combined with FromEvery, both sets of mappings apply to all event types.

TBuilder FromAll(Action<IFromAllBuilder<TReadModel>> builderCallback)

Parameters

builderCallback Action<IFromAllBuilder<TReadModel>>

Callback for building.

Returns

TBuilder

Builder continuation.

FromEvery(Action<IFromEveryBuilder<TReadModel>>)

Start building property expressions that apply to the projection's subscribed event types. When combined with FromAll, these mappings apply to all event types.

TBuilder FromEvery(Action<IFromEveryBuilder<TReadModel>> builderCallback)

Parameters

builderCallback Action<IFromEveryBuilder<TReadModel>>

Callback for building.

Returns

TBuilder

Builder continuation.

From<TEvent>(Action<IFromBuilder<TReadModel, TEvent>>?)

Start building the from expressions for a specific event type.

TBuilder From<TEvent>(Action<IFromBuilder<TReadModel, TEvent>>? builderCallback = null)

Parameters

builderCallback Action<IFromBuilder<TReadModel, TEvent>>

Optional callback for building.

Returns

TBuilder

Builder continuation.

Type Parameters

TEvent

Type of event.

Remarks

If using .AutoMap() the properties will be automatically mapped. In many cases you then don't need to provide a builder callback. You can override the mapping by providing a builder callback.

Join<TEvent>(Action<IJoinBuilder<TReadModel, TEvent>>?)

Start building a join expressions for a specific event type.

TBuilder Join<TEvent>(Action<IJoinBuilder<TReadModel, TEvent>>? builderCallback = null)

Parameters

builderCallback Action<IJoinBuilder<TReadModel, TEvent>>

Optional callback for building.

Returns

TBuilder

Builder continuation.

Type Parameters

TEvent

Type of event.

Remarks

If using .AutoMap() the properties will be automatically mapped. In many cases you then don't need to provide a builder callback. You can override the mapping by providing a builder callback.

Nested<TNestedModel>(Expression<Func<TReadModel, TNestedModel?>>, Action<INestedBuilder<TReadModel, TNestedModel>>)

Start building a nested single-object projection for a specific nested model.

TBuilder Nested<TNestedModel>(Expression<Func<TReadModel, TNestedModel?>> targetProperty, Action<INestedBuilder<TReadModel, TNestedModel>> builderCallback)

Parameters

targetProperty Expression<Func<TReadModel, TNestedModel>>

Expression for expressing the target nullable property.

builderCallback Action<INestedBuilder<TReadModel, TNestedModel>>

Builder callback.

Returns

TBuilder

Builder continuation.

Type Parameters

TNestedModel

Type of nested model.

NoAutoMap()

Disable automatic mapping of event properties to model properties.

IProjectionBuilder<TReadModel, TBuilder> NoAutoMap()

Returns

IProjectionBuilder<TReadModel, TBuilder>

Builder continuation.

Remarks

Use this to disable the default AutoMap behavior when you need explicit control over all mappings.

RemovedWithJoin<TEvent>(Action<RemovedWithJoinBuilder<TReadModel, TEvent>>?)

Defines what event removes a child through a join. This is optional, your system can chose to not support removal.

TBuilder RemovedWithJoin<TEvent>(Action<RemovedWithJoinBuilder<TReadModel, TEvent>>? builderCallback = null)

Parameters

builderCallback Action<RemovedWithJoinBuilder<TReadModel, TEvent>>

Optional callback for building.

Returns

TBuilder

Builder continuation.

Type Parameters

TEvent

Type of event.

RemovedWith<TEvent>(Action<RemovedWithBuilder<TReadModel, TEvent>>?)

Defines what event removes a child. This is optional, your system can chose to not support removal.

TBuilder RemovedWith<TEvent>(Action<RemovedWithBuilder<TReadModel, TEvent>>? builderCallback = null)

Parameters

builderCallback Action<RemovedWithBuilder<TReadModel, TEvent>>

Optional callback for building.

Returns

TBuilder

Builder continuation.

Type Parameters

TEvent

Type of event.

WithInitialValues(Func<TReadModel>)

Sets the initial values to use for a new read model instance.

TBuilder WithInitialValues(Func<TReadModel> initialValueProviderCallback)

Parameters

initialValueProviderCallback Func<TReadModel>

Callback for building.

Returns

TBuilder

Builder continuation.

Remarks

If one does not provide initial values, the projection engine will leave properties out that hasn't been met by an event projection expression. This will effectively render the properties null and might not be desirable when reading instances of the read models.