Table of Contents

Class MySqlConstraintBuilderCollection

Namespace
LfrlAnvil.MySql.Objects.Builders
Assembly
LfrlAnvil.MySql.dll

Represents a collection of SQL table constraint builders.

public sealed class MySqlConstraintBuilderCollection : SqlConstraintBuilderCollection, ISqlConstraintBuilderCollection, IReadOnlyCollection<ISqlConstraintBuilder>, IEnumerable<ISqlConstraintBuilder>, IEnumerable
Inheritance
MySqlConstraintBuilderCollection
Implements
Inherited Members
Extension Methods

Remarks

MySqlDialect implementation.

Properties

Table

Table that this collection belongs to.

public MySqlTableBuilder Table { get; }

Property Value

MySqlTableBuilder

Methods

CreateCheck(SqlConditionNode)

Creates a new check builder with a default name.

public MySqlCheckBuilder CreateCheck(SqlConditionNode condition)

Parameters

condition SqlConditionNode

Underlying condition of the check constraint.

Returns

MySqlCheckBuilder

New ISqlCheckBuilder instance.

Exceptions

SqlObjectBuilderException

When check constraint could not be created.

CreateCheck(string, SqlConditionNode)

Creates a new check builder.

public MySqlCheckBuilder CreateCheck(string name, SqlConditionNode condition)

Parameters

name string

Name of the check constraint.

condition SqlConditionNode

Underlying condition of the check constraint.

Returns

MySqlCheckBuilder

New ISqlCheckBuilder instance.

Exceptions

SqlObjectBuilderException

When check constraint could not be created.

CreateForeignKey(MySqlIndexBuilder, MySqlIndexBuilder)

Creates a new foreign key builder with a default name.

public MySqlForeignKeyBuilder CreateForeignKey(MySqlIndexBuilder originIndex, MySqlIndexBuilder referencedIndex)

Parameters

originIndex MySqlIndexBuilder

SQL index that the foreign key originates from.

referencedIndex MySqlIndexBuilder

SQL index referenced by the foreign key.

Returns

MySqlForeignKeyBuilder

New ISqlForeignKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When foreign key constraint could not be created.

CreateForeignKey(string, MySqlIndexBuilder, MySqlIndexBuilder)

Creates a new foreign key builder.

public MySqlForeignKeyBuilder CreateForeignKey(string name, MySqlIndexBuilder originIndex, MySqlIndexBuilder referencedIndex)

Parameters

name string

Name of the foreign key constraint.

originIndex MySqlIndexBuilder

SQL index that the foreign key originates from.

referencedIndex MySqlIndexBuilder

SQL index referenced by the foreign key.

Returns

MySqlForeignKeyBuilder

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.

public MySqlIndexBuilder 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

MySqlIndexBuilder

New ISqlIndexBuilder instance.

Exceptions

SqlObjectBuilderException

When index constraint could not be created.

CreateIndex(string, ReadOnlyArray<SqlOrderByNode>, bool)

Creates a new index builder.

public MySqlIndexBuilder 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

MySqlIndexBuilder

New ISqlIndexBuilder instance.

Exceptions

SqlObjectBuilderException

When index constraint could not be created.

GetCheck(string)

Returns a check with the provided name.

[Pure]
public MySqlCheckBuilder GetCheck(string name)

Parameters

name string

Name of the check to return.

Returns

MySqlCheckBuilder

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]
public MySqlForeignKeyBuilder GetForeignKey(string name)

Parameters

name string

Name of the foreign key to return.

Returns

MySqlForeignKeyBuilder

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]
public MySqlIndexBuilder GetIndex(string name)

Parameters

name string

Name of the index to return.

Returns

MySqlIndexBuilder

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]
public MySqlPrimaryKeyBuilder GetPrimaryKey()

Returns

MySqlPrimaryKeyBuilder

Existing primary key builder.

Exceptions

SqlObjectBuilderException

When primary key builder does not exist.

SetPrimaryKey(MySqlIndexBuilder)

Sets a new primary key builder with a default name.

public MySqlPrimaryKeyBuilder SetPrimaryKey(MySqlIndexBuilder index)

Parameters

index MySqlIndexBuilder

Underlying index that defines the primary key.

Returns

MySqlPrimaryKeyBuilder

New ISqlPrimaryKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When primary key constraint could not be created.

SetPrimaryKey(string, MySqlIndexBuilder)

Sets a new primary key builder.

public MySqlPrimaryKeyBuilder SetPrimaryKey(string name, MySqlIndexBuilder index)

Parameters

name string

Name of the primary key constraint.

index MySqlIndexBuilder

Underlying index that defines the primary key.

Returns

MySqlPrimaryKeyBuilder

New ISqlPrimaryKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When primary key constraint could not be created.

TryGetCheck(string)

Attempts to return a check with the provided name.

[Pure]
public MySqlCheckBuilder? TryGetCheck(string name)

Parameters

name string

Name of the check to return.

Returns

MySqlCheckBuilder

Existing check or null when check does not exist.

TryGetForeignKey(string)

Attempts to return a foreign key with the provided name.

[Pure]
public MySqlForeignKeyBuilder? TryGetForeignKey(string name)

Parameters

name string

Name of the foreign key to return.

Returns

MySqlForeignKeyBuilder

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

TryGetIndex(string)

Attempts to return an index with the provided name.

[Pure]
public MySqlIndexBuilder? TryGetIndex(string name)

Parameters

name string

Name of the index to return.

Returns

MySqlIndexBuilder

Existing index or null when index does not exist.

TryGetPrimaryKey()

Attempts to retrieve a primary key builder.

[Pure]
public MySqlPrimaryKeyBuilder? TryGetPrimaryKey()

Returns

MySqlPrimaryKeyBuilder

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