Interface IUniqueConstraintBuilder
- Namespace
- Cratis.Chronicle.Events.Constraints
- Assembly
- Cratis.Chronicle.dll
Defines the builder for building unique constraints.
public interface IUniqueConstraintBuilder
- Extension Methods
Methods
Build()
Builds the unique constraint.
IConstraintDefinition Build()
Returns
- IConstraintDefinition
A IConstraintDefinition to use for registering with server.
IgnoreCasing()
Ignore casing during comparison.
IUniqueConstraintBuilder IgnoreCasing()
Returns
- IUniqueConstraintBuilder
Builder for continuation.
On(EventType, string[])
Constrain on a specific property on an event.
IUniqueConstraintBuilder On(EventType eventType, string[] properties)
Parameters
Returns
- IUniqueConstraintBuilder
Builder for continuation.
On<TEventType>(params Expression<Func<TEventType, object>>[])
Constrain on a specific property on an event.
IUniqueConstraintBuilder On<TEventType>(params Expression<Func<TEventType, object>>[] properties)
Parameters
propertiesExpression<Func<TEventType, object>>[]Expressions for specifying the properties on the event.
Returns
- IUniqueConstraintBuilder
Builder for continuation.
Type Parameters
TEventTypeType of event the property belongs to.
RemovedWith(EventType)
Indicate an event that will remove the unique constraint.
IUniqueConstraintBuilder RemovedWith(EventType eventType)
Parameters
Returns
- IUniqueConstraintBuilder
The builder for continuation.
Remarks
Call this as many times as the lifecycle has terminal facts. Every declared event type releases the constraint on its own — declaring a second does not replace the first.
RemovedWith(EventType, string[])
Declares a removal event carrying the value to release in per-value mode.
IUniqueConstraintBuilder RemovedWith(EventType eventType, string[] properties)
Parameters
eventTypeEventTypeThe removal event type.
propertiesstring[]Property names in constrained-property order; empty releases all values.
Returns
- IUniqueConstraintBuilder
Builder for continuation.
RemovedWith<TEventType>()
Indicate an event that will remove the unique constraint.
IUniqueConstraintBuilder RemovedWith<TEventType>()
Returns
- IUniqueConstraintBuilder
Builder for continuation.
Type Parameters
TEventTypeThe EventType that removes the constraint.
Remarks
Call this as many times as the lifecycle has terminal facts. Every declared event type releases the constraint on its own — declaring a second does not replace the first.
RemovedWith<TEventType>(params Expression<Func<TEventType, object>>[])
Declares a removal event carrying the value to release in per-value mode.
IUniqueConstraintBuilder RemovedWith<TEventType>(params Expression<Func<TEventType, object>>[] properties)
Parameters
propertiesExpression<Func<TEventType, object>>[]Properties in the same order as the constrained properties; empty releases all values.
Returns
- IUniqueConstraintBuilder
Builder for continuation.
Type Parameters
TEventTypeType of removal event.
WithMessage(ConstraintViolationMessageProvider)
Specifies a provider that will provide a message to use when the unique constraint is violated.
IUniqueConstraintBuilder WithMessage(ConstraintViolationMessageProvider messageProvider)
Parameters
messageProviderConstraintViolationMessageProviderCallback that provides the message.
Returns
- IUniqueConstraintBuilder
Builder for continuation.
WithMessage(string)
Specifies a message to use when the unique constraint is violated.
IUniqueConstraintBuilder WithMessage(string message)
Parameters
messagestringMessage to use.
Returns
- IUniqueConstraintBuilder
Builder for continuation.
WithMode(UniqueConstraintMode)
Specifies how claimed values are retained; the default keeps one value per event source.
IUniqueConstraintBuilder WithMode(UniqueConstraintMode mode)
Parameters
modeUniqueConstraintModeThe retention mode.
Returns
- IUniqueConstraintBuilder
Builder for continuation.
WithName(ConstraintName)
Defines the name of the unique constraint.
IUniqueConstraintBuilder WithName(ConstraintName name)
Parameters
nameConstraintNameName to use.
Returns
- IUniqueConstraintBuilder
Builder for continuation.
Remarks
The name is optional and if not provided, it will use the type name in which the unique constraint belongs to.