Class KeyBuilder<TEvent, TBuilder>
- Namespace
- Cratis.Chronicle.Projections
- Assembly
- Cratis.Chronicle.dll
Represents a default implementation of IKeyBuilder<TEvent, TBuilder> that works with IEventValueExpression.
public class KeyBuilder<TEvent, TBuilder> : IKeyBuilder<TEvent, TBuilder> where TBuilder : class
Type Parameters
TEventEvent to build for.
TBuilderType of actual builder.
- Inheritance
-
KeyBuilder<TEvent, TBuilder>
- Implements
-
IKeyBuilder<TEvent, TBuilder>
- Derived
- Inherited Members
Constructors
KeyBuilder(INamingPolicy)
Represents a default implementation of IKeyBuilder<TEvent, TBuilder> that works with IEventValueExpression.
public KeyBuilder(INamingPolicy namingPolicy)
Parameters
namingPolicyINamingPolicyThe INamingPolicy to use for property names.
Fields
_keyExpression
protected PropertyExpression _keyExpression
Field Value
Methods
UsingCompositeKey<TKeyType>(Action<ICompositeKeyBuilder<TKeyType, TEvent>>)
Define what key to use based on a composite of expressions.
public TBuilder UsingCompositeKey<TKeyType>(Action<ICompositeKeyBuilder<TKeyType, TEvent>> builderCallback)
Parameters
builderCallbackAction<ICompositeKeyBuilder<TKeyType, TEvent>>Builder callback for building the composite key.
Returns
- TBuilder
Builder continuation.
Type Parameters
TKeyTypeType of key.
UsingConstantKey(string)
Define a constant value to use as the key. All events of this type will update the same read model instance.
public TBuilder UsingConstantKey(string value)
Parameters
valuestringThe constant value to use as key.
Returns
- TBuilder
Builder continuation.
UsingKeyFromContext<TProperty>(Expression<Func<EventContext, TProperty>>)
Define what key to use based on a value in the EventContext.
public TBuilder UsingKeyFromContext<TProperty>(Expression<Func<EventContext, TProperty>> keyAccessor)
Parameters
keyAccessorExpression<Func<EventContext, TProperty>>Accessor for the property within EventContext to use.
Returns
- TBuilder
Builder continuation.
Type Parameters
TPropertyType of the property.
UsingKey<TProperty>(Expression<Func<TEvent, TProperty>>)
Define what key to use. This is optional, if not set - it will default to using the event source identifier on the event.
public TBuilder UsingKey<TProperty>(Expression<Func<TEvent, TProperty>> keyAccessor)
Parameters
keyAccessorExpression<Func<TEvent, TProperty>>Accessor for the property to use.
Returns
- TBuilder
Builder continuation.
Type Parameters
TPropertyType of the property.