Class PostgreSqlConstraintBuilderCollection
- Namespace
- LfrlAnvil.PostgreSql.Objects.Builders
- Assembly
- LfrlAnvil.PostgreSql.dll
Represents a collection of SQL table constraint builders.
public sealed class PostgreSqlConstraintBuilderCollection : SqlConstraintBuilderCollection, ISqlConstraintBuilderCollection, IReadOnlyCollection<ISqlConstraintBuilder>, IEnumerable<ISqlConstraintBuilder>, IEnumerable
- Inheritance
-
PostgreSqlConstraintBuilderCollection
- Implements
- Inherited Members
- Extension Methods
Remarks
PostgreSqlDialect implementation.
Properties
Table
Table that this collection belongs to.
public PostgreSqlTableBuilder Table { get; }
Property Value
Methods
CreateCheck(SqlConditionNode)
Creates a new check builder with a default name.
public PostgreSqlCheckBuilder CreateCheck(SqlConditionNode condition)
Parameters
condition
SqlConditionNodeUnderlying condition of the check constraint.
Returns
- PostgreSqlCheckBuilder
New ISqlCheckBuilder instance.
Exceptions
- SqlObjectBuilderException
When check constraint could not be created.
CreateCheck(string, SqlConditionNode)
Creates a new check builder.
public PostgreSqlCheckBuilder CreateCheck(string name, SqlConditionNode condition)
Parameters
name
stringName of the check constraint.
condition
SqlConditionNodeUnderlying condition of the check constraint.
Returns
- PostgreSqlCheckBuilder
New ISqlCheckBuilder instance.
Exceptions
- SqlObjectBuilderException
When check constraint could not be created.
CreateForeignKey(PostgreSqlIndexBuilder, PostgreSqlIndexBuilder)
Creates a new foreign key builder with a default name.
public PostgreSqlForeignKeyBuilder CreateForeignKey(PostgreSqlIndexBuilder originIndex, PostgreSqlIndexBuilder referencedIndex)
Parameters
originIndex
PostgreSqlIndexBuilderSQL index that the foreign key originates from.
referencedIndex
PostgreSqlIndexBuilderSQL index referenced by the foreign key.
Returns
- PostgreSqlForeignKeyBuilder
New ISqlForeignKeyBuilder instance.
Exceptions
- SqlObjectBuilderException
When foreign key constraint could not be created.
CreateForeignKey(string, PostgreSqlIndexBuilder, PostgreSqlIndexBuilder)
Creates a new foreign key builder.
public PostgreSqlForeignKeyBuilder CreateForeignKey(string name, PostgreSqlIndexBuilder originIndex, PostgreSqlIndexBuilder referencedIndex)
Parameters
name
stringName of the foreign key constraint.
originIndex
PostgreSqlIndexBuilderSQL index that the foreign key originates from.
referencedIndex
PostgreSqlIndexBuilderSQL index referenced by the foreign key.
Returns
- PostgreSqlForeignKeyBuilder
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 PostgreSqlIndexBuilder CreateIndex(ReadOnlyArray<SqlOrderByNode> columns, bool isUnique = false)
Parameters
columns
ReadOnlyArray<SqlOrderByNode>Collection of columns that define the index.
isUnique
boolSpecifies whether or not the index should start as unique. Equal to false by default.
Returns
- PostgreSqlIndexBuilder
New ISqlIndexBuilder instance.
Exceptions
- SqlObjectBuilderException
When index constraint could not be created.
CreateIndex(string, ReadOnlyArray<SqlOrderByNode>, bool)
Creates a new index builder.
public PostgreSqlIndexBuilder CreateIndex(string name, ReadOnlyArray<SqlOrderByNode> columns, bool isUnique = false)
Parameters
name
stringName of the index constraint.
columns
ReadOnlyArray<SqlOrderByNode>Collection of columns that define the index.
isUnique
boolSpecifies whether or not the index should start as unique. Equal to false by default.
Returns
- PostgreSqlIndexBuilder
New ISqlIndexBuilder instance.
Exceptions
- SqlObjectBuilderException
When index constraint could not be created.
GetCheck(string)
Returns a check with the provided name
.
[Pure]
public PostgreSqlCheckBuilder GetCheck(string name)
Parameters
name
stringName of the check to return.
Returns
- PostgreSqlCheckBuilder
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 PostgreSqlForeignKeyBuilder GetForeignKey(string name)
Parameters
name
stringName of the foreign key to return.
Returns
- PostgreSqlForeignKeyBuilder
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 PostgreSqlIndexBuilder GetIndex(string name)
Parameters
name
stringName of the index to return.
Returns
- PostgreSqlIndexBuilder
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 PostgreSqlPrimaryKeyBuilder GetPrimaryKey()
Returns
- PostgreSqlPrimaryKeyBuilder
Existing primary key builder.
Exceptions
- SqlObjectBuilderException
When primary key builder does not exist.
SetPrimaryKey(PostgreSqlIndexBuilder)
Sets a new primary key builder with a default name.
public PostgreSqlPrimaryKeyBuilder SetPrimaryKey(PostgreSqlIndexBuilder index)
Parameters
index
PostgreSqlIndexBuilderUnderlying index that defines the primary key.
Returns
- PostgreSqlPrimaryKeyBuilder
New ISqlPrimaryKeyBuilder instance.
Exceptions
- SqlObjectBuilderException
When primary key constraint could not be created.
SetPrimaryKey(string, PostgreSqlIndexBuilder)
Sets a new primary key builder.
public PostgreSqlPrimaryKeyBuilder SetPrimaryKey(string name, PostgreSqlIndexBuilder index)
Parameters
name
stringName of the primary key constraint.
index
PostgreSqlIndexBuilderUnderlying index that defines the primary key.
Returns
- PostgreSqlPrimaryKeyBuilder
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 PostgreSqlCheckBuilder? TryGetCheck(string name)
Parameters
name
stringName of the check to return.
Returns
- PostgreSqlCheckBuilder
Existing check or null when check does not exist.
TryGetForeignKey(string)
Attempts to return a foreign key with the provided name
.
[Pure]
public PostgreSqlForeignKeyBuilder? TryGetForeignKey(string name)
Parameters
name
stringName of the foreign key to return.
Returns
- PostgreSqlForeignKeyBuilder
Existing foreign key or null when foreign key does not exist.
TryGetIndex(string)
Attempts to return an index with the provided name
.
[Pure]
public PostgreSqlIndexBuilder? TryGetIndex(string name)
Parameters
name
stringName of the index to return.
Returns
- PostgreSqlIndexBuilder
Existing index or null when index does not exist.
TryGetPrimaryKey()
Attempts to retrieve a primary key builder.
[Pure]
public PostgreSqlPrimaryKeyBuilder? TryGetPrimaryKey()
Returns
- PostgreSqlPrimaryKeyBuilder
Existing primary key builder or null when it does not exist.