Table of Contents

Interface ISqlConstraintBuilderCollection

Namespace
LfrlAnvil.Sql.Objects.Builders
Assembly
LfrlAnvil.Sql.Core.dll

Represents a collection of SQL table constraint builders.

public interface ISqlConstraintBuilderCollection : IReadOnlyCollection<ISqlConstraintBuilder>, IEnumerable<ISqlConstraintBuilder>, IEnumerable
Inherited Members
Extension Methods

Properties

Table

Table that this collection belongs to.

ISqlTableBuilder Table { get; }

Property Value

ISqlTableBuilder

Methods

Contains(string)

Checks whether or not a constraint with the provided name exists.

[Pure]
bool Contains(string name)

Parameters

name string

Name to check.

Returns

bool

true when constraint exists, otherwise false.

CreateCheck(SqlConditionNode)

Creates a new check builder with a default name.

ISqlCheckBuilder CreateCheck(SqlConditionNode condition)

Parameters

condition SqlConditionNode

Underlying condition of the check constraint.

Returns

ISqlCheckBuilder

New ISqlCheckBuilder instance.

Exceptions

SqlObjectBuilderException

When check constraint could not be created.

CreateCheck(string, SqlConditionNode)

Creates a new check builder.

ISqlCheckBuilder CreateCheck(string name, SqlConditionNode condition)

Parameters

name string

Name of the check constraint.

condition SqlConditionNode

Underlying condition of the check constraint.

Returns

ISqlCheckBuilder

New ISqlCheckBuilder instance.

Exceptions

SqlObjectBuilderException

When check constraint could not be created.

CreateForeignKey(ISqlIndexBuilder, ISqlIndexBuilder)

Creates a new foreign key builder with a default name.

ISqlForeignKeyBuilder CreateForeignKey(ISqlIndexBuilder originIndex, ISqlIndexBuilder referencedIndex)

Parameters

originIndex ISqlIndexBuilder

SQL index that the foreign key originates from.

referencedIndex ISqlIndexBuilder

SQL index referenced by the foreign key.

Returns

ISqlForeignKeyBuilder

New ISqlForeignKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When foreign key constraint could not be created.

CreateForeignKey(string, ISqlIndexBuilder, ISqlIndexBuilder)

Creates a new foreign key builder.

ISqlForeignKeyBuilder CreateForeignKey(string name, ISqlIndexBuilder originIndex, ISqlIndexBuilder referencedIndex)

Parameters

name string

Name of the foreign key constraint.

originIndex ISqlIndexBuilder

SQL index that the foreign key originates from.

referencedIndex ISqlIndexBuilder

SQL index referenced by the foreign key.

Returns

ISqlForeignKeyBuilder

New ISqlForeignKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When foreign key constraint could not be created.

CreateIndex(ReadOnlyArray<SqlOrderByNode>, bool)

Creates a new index builder with a default name.

ISqlIndexBuilder CreateIndex(ReadOnlyArray<SqlOrderByNode> columns, bool isUnique = false)

Parameters

columns ReadOnlyArray<SqlOrderByNode>

Collection of columns that define the index.

isUnique bool

Specifies whether or not the index should start as unique. Equal to false by default.

Returns

ISqlIndexBuilder

New ISqlIndexBuilder instance.

Exceptions

SqlObjectBuilderException

When index constraint could not be created.

CreateIndex(string, ReadOnlyArray<SqlOrderByNode>, bool)

Creates a new index builder.

ISqlIndexBuilder CreateIndex(string name, ReadOnlyArray<SqlOrderByNode> columns, bool isUnique = false)

Parameters

name string

Name of the index constraint.

columns ReadOnlyArray<SqlOrderByNode>

Collection of columns that define the index.

isUnique bool

Specifies whether or not the index should start as unique. Equal to false by default.

Returns

ISqlIndexBuilder

New ISqlIndexBuilder instance.

Exceptions

SqlObjectBuilderException

When index constraint could not be created.

Get(string)

Returns a constraint with the provided name.

[Pure]
ISqlConstraintBuilder Get(string name)

Parameters

name string

Name of the constraint to return.

Returns

ISqlConstraintBuilder

Existing constraint.

Exceptions

KeyNotFoundException

When constraint does not exist.

GetCheck(string)

Returns a check with the provided name.

[Pure]
ISqlCheckBuilder GetCheck(string name)

Parameters

name string

Name of the check to return.

Returns

ISqlCheckBuilder

Existing check.

Exceptions

KeyNotFoundException

When check does not exist.

SqlObjectCastException

When constraint exists but is not a check.

GetForeignKey(string)

Returns a foreign key with the provided name.

[Pure]
ISqlForeignKeyBuilder GetForeignKey(string name)

Parameters

name string

Name of the foreign key to return.

Returns

ISqlForeignKeyBuilder

Existing foreign key.

Exceptions

KeyNotFoundException

When foreign key does not exist.

SqlObjectCastException

When constraint exists but is not a foreign key.

GetIndex(string)

Returns an index with the provided name.

[Pure]
ISqlIndexBuilder GetIndex(string name)

Parameters

name string

Name of the index to return.

Returns

ISqlIndexBuilder

Existing index.

Exceptions

KeyNotFoundException

When index does not exist.

SqlObjectCastException

When constraint exists but is not an index.

GetPrimaryKey()

Retrieves a primary key builder.

[Pure]
ISqlPrimaryKeyBuilder GetPrimaryKey()

Returns

ISqlPrimaryKeyBuilder

Existing primary key builder.

Exceptions

SqlObjectBuilderException

When primary key builder does not exist.

Remove(string)

Attempts to remove a constraint by its name.

bool Remove(string name)

Parameters

name string

Name of the constraint to remove.

Returns

bool

true when constraint was removed, otherwise false.

SetPrimaryKey(ISqlIndexBuilder)

Sets a new primary key builder with a default name.

ISqlPrimaryKeyBuilder SetPrimaryKey(ISqlIndexBuilder index)

Parameters

index ISqlIndexBuilder

Underlying index that defines the primary key.

Returns

ISqlPrimaryKeyBuilder

New ISqlPrimaryKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When primary key constraint could not be created.

SetPrimaryKey(string, ISqlIndexBuilder)

Sets a new primary key builder.

ISqlPrimaryKeyBuilder SetPrimaryKey(string name, ISqlIndexBuilder index)

Parameters

name string

Name of the primary key constraint.

index ISqlIndexBuilder

Underlying index that defines the primary key.

Returns

ISqlPrimaryKeyBuilder

New ISqlPrimaryKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When primary key constraint could not be created.

TryGet(string)

Attempts to return a constraint with the provided name.

[Pure]
ISqlConstraintBuilder? TryGet(string name)

Parameters

name string

Name of the constraint to return.

Returns

ISqlConstraintBuilder

Existing constraint or null when constraint does not exist.

TryGetCheck(string)

Attempts to return a check with the provided name.

[Pure]
ISqlCheckBuilder? TryGetCheck(string name)

Parameters

name string

Name of the check to return.

Returns

ISqlCheckBuilder

Existing check or null when check does not exist.

TryGetForeignKey(string)

Attempts to return a foreign key with the provided name.

[Pure]
ISqlForeignKeyBuilder? TryGetForeignKey(string name)

Parameters

name string

Name of the foreign key to return.

Returns

ISqlForeignKeyBuilder

Existing foreign key or null when foreign key does not exist.

TryGetIndex(string)

Attempts to return an index with the provided name.

[Pure]
ISqlIndexBuilder? TryGetIndex(string name)

Parameters

name string

Name of the index to return.

Returns

ISqlIndexBuilder

Existing index or null when index does not exist.

TryGetPrimaryKey()

Attempts to retrieve a primary key builder.

[Pure]
ISqlPrimaryKeyBuilder? TryGetPrimaryKey()

Returns

ISqlPrimaryKeyBuilder

Existing primary key builder or null when it does not exist.