Table of Contents

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

Constructors

UniqueConstraintBuilder(IEventTypes, Type?)

Represents an implementation of IUniqueConstraintBuilder.

public UniqueConstraintBuilder(IEventTypes eventTypes, Type? owner = null)

Parameters

eventTypes IEventTypes

Event types for the builder.

owner Type

Optional 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

eventType EventType

The EventType the property belongs to.

properties string[]

Property names.

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

properties Expression<Func<TEventType, object>>[]

Expressions for specifying the properties on the event.

Returns

IUniqueConstraintBuilder

Builder for continuation.

Type Parameters

TEventType

Type of event the property belongs to.

RemovedWith(EventType)

Indicate an event that will remove the unique constraint.

public IUniqueConstraintBuilder RemovedWith(EventType eventType)

Parameters

eventType EventType

The EventType that would remove the constraint.

Returns

IUniqueConstraintBuilder

The 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

TEventType

The EventType that removes the constraint.

WithMessage(ConstraintViolationMessageProvider)

Specifies a provider that will provide a message to use when the unique constraint is violated.

public IUniqueConstraintBuilder WithMessage(ConstraintViolationMessageProvider messageProvider)

Parameters

messageProvider ConstraintViolationMessageProvider

Callback 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

message string

Message to use.

Returns

IUniqueConstraintBuilder

Builder for continuation.

WithName(ConstraintName)

Defines the name of the unique constraint.

public IUniqueConstraintBuilder WithName(ConstraintName name)

Parameters

name ConstraintName

Name 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.