Class SqlIndexBuilder
Represents an SQL index constraint builder.
public abstract class SqlIndexBuilder : SqlConstraintBuilder, ISqlIndexBuilder, ISqlConstraintBuilder, ISqlObjectBuilder
- Inheritance
-
SqlIndexBuilder
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
SqlIndexBuilder(SqlTableBuilder, string, SqlIndexBuilderColumns<SqlColumnBuilder>, bool, ReadOnlyArray<SqlColumnBuilder>)
Creates a new SqlIndexBuilder instance.
protected SqlIndexBuilder(SqlTableBuilder table, string name, SqlIndexBuilderColumns<SqlColumnBuilder> columns, bool isUnique, ReadOnlyArray<SqlColumnBuilder> referencedColumns)
Parameters
table
SqlTableBuilderTable that this constraint is attached to.
name
stringObject's name.
columns
SqlIndexBuilderColumns<SqlColumnBuilder>Collection of columns that define this index.
isUnique
boolSpecifies whether or not this index is unique.
referencedColumns
ReadOnlyArray<SqlColumnBuilder>Collection of columns referenced by this index's Columns.
Properties
CanRemove
Specifies whether or not this object can be removed.
public override bool CanRemove { get; }
Property Value
Columns
Collection of columns that define this index.
public SqlIndexBuilderColumns<SqlColumnBuilder> Columns { get; }
Property Value
Filter
Specifies an optional filter condition of this index.
public SqlConditionNode? Filter { get; }
Property Value
IsUnique
Specifies whether or not this index is unique.
public bool IsUnique { get; }
Property Value
IsVirtual
Specifies whether or not this index is virtual.
public bool IsVirtual { get; }
Property Value
Remarks
Virtual indexes aren't actually created in the database.
PrimaryKey
Optional ISqlPrimaryKeyBuilder instance attached to this index.
public SqlPrimaryKeyBuilder? PrimaryKey { get; }
Property Value
ReferencedColumns
Collection of columns referenced by this index's Columns.
public SqlObjectBuilderArray<SqlColumnBuilder> ReferencedColumns { get; }
Property Value
ReferencedFilterColumns
Collection of columns referenced by this index's Filter.
public SqlObjectBuilderArray<SqlColumnBuilder> ReferencedFilterColumns { get; }
Property Value
Methods
AfterFilterChange(SqlConditionNode?)
Callback invoked just after Filter change has been processed.
protected virtual void AfterFilterChange(SqlConditionNode? originalValue)
Parameters
originalValue
SqlConditionNodeOriginal value.
AfterIsUniqueChange(bool)
Callback invoked just after IsUnique change has been processed.
protected virtual void AfterIsUniqueChange(bool originalValue)
Parameters
originalValue
boolOriginal value.
AfterIsVirtualChange(bool)
Callback invoked just after IsVirtual change has been processed.
protected virtual void AfterIsVirtualChange(bool originalValue)
Parameters
originalValue
boolOriginal value.
AfterPrimaryKeyChange(SqlPrimaryKeyBuilder?)
Callback invoked just after PrimaryKey change has been processed.
protected virtual void AfterPrimaryKeyChange(SqlPrimaryKeyBuilder? originalValue)
Parameters
originalValue
SqlPrimaryKeyBuilderOriginal value.
AfterRemove()
Callback invoked just after the removal has been processed.
protected override void AfterRemove()
BeforeFilterChange(SqlConditionNode?)
Callback invoked just before Filter change is processed.
protected virtual SqlPropertyChange<SqlConditionNode?> BeforeFilterChange(SqlConditionNode? newValue)
Parameters
newValue
SqlConditionNodeValue to set.
Returns
- SqlPropertyChange<SqlConditionNode>
SqlPropertyChange<T> instance associated with Filter change attempt.
Exceptions
- SqlObjectBuilderException
When Filter of this index cannot be changed.
BeforeIsUniqueChange(bool)
Callback invoked just before IsUnique change is processed.
protected virtual SqlPropertyChange<bool> BeforeIsUniqueChange(bool newValue)
Parameters
newValue
boolValue to set.
Returns
- SqlPropertyChange<bool>
SqlPropertyChange<T> instance associated with IsUnique change attempt.
Exceptions
- SqlObjectBuilderException
When IsUnique of this index cannot be changed.
BeforeIsVirtualChange(bool)
Callback invoked just before IsVirtual change is processed.
protected virtual SqlPropertyChange<bool> BeforeIsVirtualChange(bool newValue)
Parameters
newValue
boolValue to set.
Returns
- SqlPropertyChange<bool>
SqlPropertyChange<T> instance associated with IsVirtual change attempt.
Exceptions
- SqlObjectBuilderException
When IsVirtual of this index cannot be changed.
BeforeRemove()
Callback invoked just before the removal is processed.
protected override void BeforeRemove()
Exceptions
- SqlObjectBuilderException
When this object cannot be removed.
ClearColumnReferences()
Removes all columns from ReferencedColumns and removes this index from their reference sources.
protected void ClearColumnReferences()
ClearFilterColumnReferences()
Removes all columns from ReferencedFilterColumns and removes this index's Filter from their reference sources.
protected void ClearFilterColumnReferences()
CreateFilterConditionValidator()
Creates a new SqlTableScopeExpressionValidator used for Filter condition validation.
[Pure]
protected virtual SqlTableScopeExpressionValidator CreateFilterConditionValidator()
Returns
GetDefaultName()
Creates a default name for this constraint.
[Pure]
protected override sealed string GetDefaultName()
Returns
- string
Default name for this constraint.
MarkAsUnique(bool)
Changes IsUnique value of this index.
public SqlIndexBuilder MarkAsUnique(bool enabled = true)
Parameters
enabled
boolValue to set. Equal to true by default.
Returns
- SqlIndexBuilder
this.
Exceptions
- SqlObjectBuilderException
When uniqueness cannot be changed.
MarkAsVirtual(bool)
Changes IsVirtual value of this index.
public SqlIndexBuilder MarkAsVirtual(bool enabled = true)
Parameters
enabled
boolValue to set. Equal to true by default.
Returns
- SqlIndexBuilder
this.
Exceptions
- SqlObjectBuilderException
When virtuality cannot be changed.
QuickRemoveCore()
Performs a quick removal of this object.
protected override void QuickRemoveCore()
Remarks
See QuickRemove(SqlObjectBuilder) for more information.
SetColumnReferences(SqlIndexBuilderColumns<SqlColumnBuilder>, ReadOnlyArray<SqlColumnBuilder>)
Adds a collection of referencedColumns
to ReferencedColumns
and adds this index to their reference sources.
protected void SetColumnReferences(SqlIndexBuilderColumns<SqlColumnBuilder> columns, ReadOnlyArray<SqlColumnBuilder> referencedColumns)
Parameters
columns
SqlIndexBuilderColumns<SqlColumnBuilder>Collection of columns that define this index.
referencedColumns
ReadOnlyArray<SqlColumnBuilder>Collection of columns to add.
SetDefaultName()
Changes the name of this object to a default name.
public SqlIndexBuilder SetDefaultName()
Returns
- SqlIndexBuilder
this.
Remarks
See ISqlDefaultObjectNameProvider for more information.
Exceptions
- SqlObjectBuilderException
When name cannot be changed.
SetFilter(SqlConditionNode?)
Changes Filter value of this index.
public SqlIndexBuilder SetFilter(SqlConditionNode? filter)
Parameters
filter
SqlConditionNodeValue to set.
Returns
- SqlIndexBuilder
this.
Exceptions
- SqlObjectBuilderException
When filter cannot be changed.
SetFilterColumnReferences(ReadOnlyArray<SqlColumnBuilder>)
Adds a collection of columns
to ReferencedFilterColumns
and adds this index's Filter to their reference sources.
protected void SetFilterColumnReferences(ReadOnlyArray<SqlColumnBuilder> columns)
Parameters
columns
ReadOnlyArray<SqlColumnBuilder>Collection of columns to add.
SetName(string)
Changes the name of this object.
public SqlIndexBuilder SetName(string name)
Parameters
name
stringName to set.
Returns
- SqlIndexBuilder
this.
Exceptions
- SqlObjectBuilderException
When name cannot be changed.
ThrowIfCannotBePartial()
Throws an exception when this index cannot be partial.
protected void ThrowIfCannotBePartial()
Remarks
Index cannot be assigned to a primary key, cannot be virtual and cannot be referenced by any foreign key.
Exceptions
- SqlObjectBuilderException
When index cannot be partial.
ThrowIfCannotBeUnique()
Throws an exception when this index cannot be unique.
protected void ThrowIfCannotBeUnique()
Remarks
Index cannot be virtual and all columns must be single column expressions.
Exceptions
- SqlObjectBuilderException
When index cannot be unique.
ThrowIfCannotBeVirtual()
Throws an exception when this index cannot be virtual.
protected void ThrowIfCannotBeVirtual()
Remarks
Index cannot be unique, cannot be partial and cannot be referenced by any foreign key.
Exceptions
- SqlObjectBuilderException
When index cannot be virtual.
ThrowIfMustRemainUnique()
Throws an exception when this index cannot be non-unique.
protected void ThrowIfMustRemainUnique()
Remarks
Index cannot be assigned to a primary key and cannot be referenced by any foreign key.
Exceptions
- SqlObjectBuilderException
When index cannot be non-unique.
ThrowIfMustRemainVirtual()
Throws an exception when this index cannot be non-virtual.
protected void ThrowIfMustRemainVirtual()
Remarks
Index cannot be assigned to a primary key.
Exceptions
- SqlObjectBuilderException
When index cannot be non-virtual.
ValidateFilterCondition(SqlConditionNode)
Checks if the provided condition is a valid Filter condition.
[Pure]
protected ReadOnlyArray<SqlColumnBuilder> ValidateFilterCondition(SqlConditionNode condition)
Parameters
condition
SqlConditionNodeCondition to check.
Returns
- ReadOnlyArray<SqlColumnBuilder>
Collection of columns referenced by the
condition
.
Remarks
CreateFilterConditionValidator() creates condition's validator.
Exceptions
- SqlObjectBuilderException
When
condition
is not valid.