Class ReadModelPropertiesBuilder<TReadModel, TEvent, TBuilder, TParentBuilder>

Namespace
Cratis.Chronicle.Projections
Assembly
Cratis.Chronicle.dll
public class ReadModelPropertiesBuilder<TReadModel, TEvent, TBuilder, TParentBuilder> : KeyAndParentKeyBuilder<TEvent, TBuilder>, IKeyBuilder<TEvent, TBuilder>, IParentKeyBuilder<TEvent, TBuilder>, IReadModelPropertiesBuilder<TReadModel, TEvent, TBuilder> where TBuilder : class, IReadModelPropertiesBuilder<TReadModel, TEvent, TBuilder> where TParentBuilder : class

Type Parameters

TReadModel

Read model to build for.

TEvent

Event to build for.

TBuilder

Type of actual builder.

TParentBuilder

The type of parent builder.

Inheritance
KeyBuilder<TEvent, TBuilder>
KeyAndParentKeyBuilder<TEvent, TBuilder>
ReadModelPropertiesBuilder<TReadModel, TEvent, TBuilder, TParentBuilder>
Implements
IKeyBuilder<TEvent, TBuilder>
IParentKeyBuilder<TEvent, TBuilder>
IReadModelPropertiesBuilder<TReadModel, TEvent, TBuilder>
Derived
Inherited Members
Extension Methods

Constructors

ReadModelPropertiesBuilder(IProjectionBuilder<TReadModel, TParentBuilder>, INamingPolicy)

public ReadModelPropertiesBuilder(IProjectionBuilder<TReadModel, TParentBuilder> projectionBuilder, INamingPolicy namingPolicy)

Parameters

projectionBuilder IProjectionBuilder<TReadModel, TParentBuilder>

The parent IProjectionBuilderFor<TReadModel>.

namingPolicy INamingPolicy

The INamingPolicy to use for converting names during serialization.

Fields

_propertyExpressions

protected readonly Dictionary<PropertyPath, IPropertyExpressionBuilder> _propertyExpressions

Field Value

Dictionary<PropertyPath, IPropertyExpressionBuilder>

Methods

AddChild<TChildModel>(Expression<Func<TReadModel, IEnumerable<TChildModel>>>, Action<IAddChildBuilder<TChildModel, TEvent>>)

Start building the add child operation to a target property holding an collection of a specific child model type.

public TBuilder AddChild<TChildModel>(Expression<Func<TReadModel, IEnumerable<TChildModel>>> targetProperty, Action<IAddChildBuilder<TChildModel, TEvent>> builderCallback)

Parameters

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

The collection property that will receive the child.

builderCallback Action<IAddChildBuilder<TChildModel, TEvent>>

Builder callback for building the composite key.

Returns

TBuilder

Builder continuation.

Type Parameters

TChildModel

Type of child model.

AddChild<TChildModel>(Expression<Func<TReadModel, IEnumerable<TChildModel>>>, Expression<Func<TEvent, TChildModel>>)

Start building a child operation that add a child based on a property on the event.

public TBuilder AddChild<TChildModel>(Expression<Func<TReadModel, IEnumerable<TChildModel>>> targetProperty, Expression<Func<TEvent, TChildModel>> eventProperty)

Parameters

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

The collection property that will receive the child.

eventProperty Expression<Func<TEvent, TChildModel>>

Event property accessor for defining the source property.

Returns

TBuilder

Builder continuation.

Type Parameters

TChildModel

Type of child model.

Add<TProperty>(Expression<Func<TReadModel, TProperty>>)

Start building the add operation to a target property on the model.

public IAddBuilder<TReadModel, TEvent, TProperty, TBuilder> Add<TProperty>(Expression<Func<TReadModel, TProperty>> readModelPropertyAccessor)

Parameters

readModelPropertyAccessor Expression<Func<TReadModel, TProperty>>

Model property accessor for defining the target property.

Returns

IAddBuilder<TReadModel, TEvent, TProperty, TBuilder>

Builder continuation.

Type Parameters

TProperty

Type of the property.

Clear<TProperty>(Expression<Func<TReadModel, TProperty>>)

Clear a property on the model, returning it to no value.

public TBuilder Clear<TProperty>(Expression<Func<TReadModel, TProperty>> readModelPropertyAccessor)

Parameters

readModelPropertyAccessor Expression<Func<TReadModel, TProperty>>

Model property accessor for defining the target property.

Returns

TBuilder

Builder continuation.

Type Parameters

TProperty

Type of the property.

Remarks

Clearing is its own operation rather than a set of a special value: the member is written back to null every time the event is observed, replay included. The property has to be able to hold null - clearing one that cannot is refused here, because the only value that could be written is the type default, which is a different fact than "no value". Use Set(...).ToValue(...) when a type default is what you mean. The default implementation throws, so adding this member does not break an implementation outside this assembly: it keeps compiling, and only fails if it is actually asked to clear something.

Exceptions

CannotClearNonNullableMember

Thrown when the target property cannot hold null.

ClearNotSupported

Thrown when an alternate builder implementation does not support clearing a member.

Count<TProperty>(Expression<Func<TReadModel, TProperty>>)

Start building the count operation to a target property on the model.

public TBuilder Count<TProperty>(Expression<Func<TReadModel, TProperty>> readModelPropertyAccessor)

Parameters

readModelPropertyAccessor Expression<Func<TReadModel, TProperty>>

Model property accessor for defining the target property.

Returns

TBuilder

Builder continuation.

Type Parameters

TProperty

Type of the property.

Decrement<TProperty>(Expression<Func<TReadModel, TProperty>>)

Increment the value of a property on the model.

public TBuilder Decrement<TProperty>(Expression<Func<TReadModel, TProperty>> readModelPropertyAccessor)

Parameters

readModelPropertyAccessor Expression<Func<TReadModel, TProperty>>

Model property accessor for defining the target property.

Returns

TBuilder

Builder continuation.

Type Parameters

TProperty

Type of the property.

Increment<TProperty>(Expression<Func<TReadModel, TProperty>>)

Increment the value of a property on the model.

public TBuilder Increment<TProperty>(Expression<Func<TReadModel, TProperty>> readModelPropertyAccessor)

Parameters

readModelPropertyAccessor Expression<Func<TReadModel, TProperty>>

Model property accessor for defining the target property.

Returns

TBuilder

Builder continuation.

Type Parameters

TProperty

Type of the property.

Set(PropertyPath)

Start building the set operation to a target property on the model.

public ISetBuilder<TReadModel, TEvent, TBuilder> Set(PropertyPath propertyPath)

Parameters

propertyPath PropertyPath

Model property path for defining the target property.

Returns

ISetBuilder<TReadModel, TEvent, TBuilder>

The ISetBuilder<TReadModel, TEvent, TParentBuilder> to continue building on.

SetThisValue()

Start building the set operation to target the value instance itself.

public ISetBuilder<TReadModel, TEvent, TBuilder> SetThisValue()

Returns

ISetBuilder<TReadModel, TEvent, TBuilder>

The ISetBuilder<TReadModel, TEvent, TParentBuilder> to continue building on.

Set<TProperty>(Expression<Func<TReadModel, TProperty>>)

Start building the set operation to a target property on the model.

public ISetBuilder<TReadModel, TEvent, TProperty, TBuilder> Set<TProperty>(Expression<Func<TReadModel, TProperty>> readModelPropertyAccessor)

Parameters

readModelPropertyAccessor Expression<Func<TReadModel, TProperty>>

Model property accessor for defining the target property.

Returns

ISetBuilder<TReadModel, TEvent, TProperty, TBuilder>

The ISetBuilder<TReadModel, TEvent, TProperty, TParentBuilder> to continue building on.

Type Parameters

TProperty

Type of the property.

Subtract<TProperty>(Expression<Func<TReadModel, TProperty>>)

Start building the add operation to a target property on the model.

public ISubtractBuilder<TReadModel, TEvent, TProperty, TBuilder> Subtract<TProperty>(Expression<Func<TReadModel, TProperty>> readModelPropertyAccessor)

Parameters

readModelPropertyAccessor Expression<Func<TReadModel, TProperty>>

Model property accessor for defining the target property.

Returns

ISubtractBuilder<TReadModel, TEvent, TProperty, TBuilder>

Builder continuation.

Type Parameters

TProperty

Type of the property.