Class AddChildBuilder<TParentModel, TChildModel, TEvent>
- Namespace
- Cratis.Chronicle.Projections
- Assembly
- Cratis.Chronicle.dll
Represents an implementation of IAddChildBuilder<TChildModel, TEvent>.
public class AddChildBuilder<TParentModel, TChildModel, TEvent> : IAddChildBuilder<TChildModel, TEvent>
Type Parameters
TParentModel
Parent model type.
TChildModel
Child model type.
TEvent
Type of the event.
- Inheritance
-
AddChildBuilder<TParentModel, TChildModel, TEvent>
- Implements
-
IAddChildBuilder<TChildModel, TEvent>
- Inherited Members
Remarks
Initializes a new instance of the AddChildBuilder<TParentModel, TChildModel, TEvent> class.
Constructors
AddChildBuilder(IChildrenBuilder<TParentModel, TChildModel>, IFromBuilder<TChildModel, TEvent>)
Represents an implementation of IAddChildBuilder<TChildModel, TEvent>.
public AddChildBuilder(IChildrenBuilder<TParentModel, TChildModel> childrenBuilder, IFromBuilder<TChildModel, TEvent> fromBuilder)
Parameters
childrenBuilder
IChildrenBuilder<TParentModel, TChildModel>The children builder to use internally.
fromBuilder
IFromBuilder<TChildModel, TEvent>The IFromBuilder<TModel, TEvent> to build the internals of the child relationship.
Remarks
Initializes a new instance of the AddChildBuilder<TParentModel, TChildModel, TEvent> class.
Methods
FromObject(Expression<Func<TEvent, TChildModel>>)
Describe an adding of a child from an object already on the event.
public IAddChildBuilder<TChildModel, TEvent> FromObject(Expression<Func<TEvent, TChildModel>> propertyWithChild)
Parameters
propertyWithChild
Expression<Func<TEvent, TChildModel>>The property that holds object on the event.
Returns
- IAddChildBuilder<TChildModel, TEvent>
Parent builder for continuation.
IdentifiedBy<TProperty>(Expression<Func<TChildModel, TProperty>>)
Sets the property that identifies the child model in the collection within the parent.
public IAddChildBuilder<TChildModel, TEvent> IdentifiedBy<TProperty>(Expression<Func<TChildModel, TProperty>> propertyExpression)
Parameters
propertyExpression
Expression<Func<TChildModel, TProperty>>The expression that represents the property used to identify.
Returns
- IAddChildBuilder<TChildModel, TEvent>
Builder continuation.
Type Parameters
TProperty
Type of property.
UsingKeyFromContext<TProperty>(Expression<Func<EventContext, TProperty>>)
Define what key to use based on a value in the EventContext.
public IAddChildBuilder<TChildModel, TEvent> UsingKeyFromContext<TProperty>(Expression<Func<EventContext, TProperty>> keyAccessor)
Parameters
keyAccessor
Expression<Func<EventContext, TProperty>>Accessor for the property within EventContext to use.
Returns
- IAddChildBuilder<TChildModel, TEvent>
Builder continuation.
Type Parameters
TProperty
Type 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 IAddChildBuilder<TChildModel, TEvent> UsingKey<TProperty>(Expression<Func<TEvent, TProperty>> keyAccessor)
Parameters
keyAccessor
Expression<Func<TEvent, TProperty>>Accessor for the property to use.
Returns
- IAddChildBuilder<TChildModel, TEvent>
Builder continuation.
Type Parameters
TProperty
Type of the property.
UsingParentCompositeKey<TKeyType>(Action<ICompositeKeyBuilder<TKeyType, TEvent>>)
Define what composite key based on properties on the event represents the parent key. This is typically used in child relationships to identify the parent model to work with.
public IAddChildBuilder<TChildModel, TEvent> UsingParentCompositeKey<TKeyType>(Action<ICompositeKeyBuilder<TKeyType, TEvent>> builderCallback)
Parameters
builderCallback
Action<ICompositeKeyBuilder<TKeyType, TEvent>>Builder callback for building the composite key.
Returns
- IAddChildBuilder<TChildModel, TEvent>
Builder continuation.
Type Parameters
TKeyType
Type of key.
UsingParentKeyFromContext<TProperty>(Expression<Func<EventContext, TProperty>>)
Define what property on the event represents the parent key based on a property in the EventContext. This is typically used in child relationships to identify the parent model to work with.
public IAddChildBuilder<TChildModel, TEvent> UsingParentKeyFromContext<TProperty>(Expression<Func<EventContext, TProperty>> keyAccessor)
Parameters
keyAccessor
Expression<Func<EventContext, TProperty>>Accessor for the property to use.
Returns
- IAddChildBuilder<TChildModel, TEvent>
Builder continuation.
Type Parameters
TProperty
Type of the property.
UsingParentKey<TProperty>(Expression<Func<TEvent, TProperty>>)
Define what property on the event represents the parent key. This is typically used in child relationships to identify the parent model to work with.
public IAddChildBuilder<TChildModel, TEvent> UsingParentKey<TProperty>(Expression<Func<TEvent, TProperty>> keyAccessor)
Parameters
keyAccessor
Expression<Func<TEvent, TProperty>>Accessor for the property to use.
Returns
- IAddChildBuilder<TChildModel, TEvent>
Builder continuation.
Type Parameters
TProperty
Type of the property.