Class UniqueConstraintBuilder
- Namespace
- Cratis.Chronicle.Events.Constraints
- Assembly
- Cratis.Chronicle.dll
Represents an implementation of IUniqueConstraintBuilder.
public class UniqueConstraintBuilder : IUniqueConstraintBuilder
- Inheritance
-
UniqueConstraintBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
UniqueConstraintBuilder(IEventTypes, INamingPolicy, Type?)
Represents an implementation of IUniqueConstraintBuilder.
public UniqueConstraintBuilder(IEventTypes eventTypes, INamingPolicy namingPolicy, Type? owner = null)
Parameters
eventTypesIEventTypesEvent types for the builder.
namingPolicyINamingPolicyThe INamingPolicy to use for converting names during serialization.
ownerTypeOptional owner of the constraint.
Methods
Build()
Builds the unique constraint.
public IConstraintDefinition Build()
Returns
- IConstraintDefinition
A IConstraintDefinition to use for registering with server.
IgnoreCasing()
Ignore casing during comparison.
public IUniqueConstraintBuilder IgnoreCasing()
Returns
- IUniqueConstraintBuilder
Builder for continuation.
On(EventType, params string[])
Constrain on a specific property on an event.
public IUniqueConstraintBuilder On(EventType eventType, params string[] properties)
Parameters
Returns
- IUniqueConstraintBuilder
Builder for continuation.
On<TEventType>(params Expression<Func<TEventType, object>>[])
Constrain on a specific property on an event.
public 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.
public 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.
public 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.
public 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.
public 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.
public 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.
public 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.
public IUniqueConstraintBuilder WithMode(UniqueConstraintMode mode)
Parameters
modeUniqueConstraintModeThe retention mode.
Returns
- IUniqueConstraintBuilder
Builder for continuation.
WithName(ConstraintName)
Defines the name of the unique constraint.
public 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.