Class SqlColumnBuilderCollection
Represents a collection of SQL table column builders.
public abstract class SqlColumnBuilderCollection : SqlBuilderApi, ISqlColumnBuilderCollection, IReadOnlyCollection<ISqlColumnBuilder>, IEnumerable<ISqlColumnBuilder>, IEnumerable
- Inheritance
-
SqlColumnBuilderCollection
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
SqlColumnBuilderCollection(SqlColumnTypeDefinition)
Creates a new empty SqlColumnBuilderCollection instance.
protected SqlColumnBuilderCollection(SqlColumnTypeDefinition defaultTypeDefinition)
Parameters
defaultTypeDefinition
SqlColumnTypeDefinitionSpecifies the default SqlColumnTypeDefinition of newly created columns.
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
DefaultTypeDefinition
Specifies the default ISqlColumnTypeDefinition of newly created columns.
public SqlColumnTypeDefinition DefaultTypeDefinition { get; }
Property Value
Table
Table that this collection belongs to.
public SqlTableBuilder Table { get; }
Property Value
Methods
AfterCreateColumn(SqlColumnBuilder)
Callback invoked just after the column
creation has been processed.
protected virtual void AfterCreateColumn(SqlColumnBuilder column)
Parameters
column
SqlColumnBuilderCreated column.
Contains(string)
Checks whether or not a column with the provided name
exists.
[Pure]
public bool Contains(string name)
Parameters
name
stringName to check.
Returns
- bool
true when column exists, otherwise false.
Create(string)
Creates a new column builder.
public SqlColumnBuilder Create(string name)
Parameters
name
stringName of the column.
Returns
- SqlColumnBuilder
New ISqlColumnBuilder instance.
Exceptions
- SqlObjectBuilderException
When column could not be created.
CreateColumnBuilder(string)
Creates a new SqlColumnBuilder instance.
protected abstract SqlColumnBuilder CreateColumnBuilder(string name)
Parameters
name
stringColumn's name.
Returns
- SqlColumnBuilder
New SqlColumnBuilder instance.
Get(string)
Returns a column with the provided name
.
[Pure]
public SqlColumnBuilder Get(string name)
Parameters
name
stringName of the column to return.
Returns
- SqlColumnBuilder
Existing column.
Exceptions
- KeyNotFoundException
When column does not exist.
GetEnumerator()
Creates a new SqlObjectBuilderEnumerator<T> instance for this collection.
[Pure]
public SqlObjectBuilderEnumerator<SqlColumnBuilder> GetEnumerator()
Returns
GetOrCreate(string)
Creates a new column builder or returns an existing column builder.
public SqlColumnBuilder GetOrCreate(string name)
Parameters
name
stringName of the column.
Returns
- SqlColumnBuilder
New ISqlColumnBuilder instance or an existing column builder.
Exceptions
- SqlObjectBuilderException
When column does not exist and could not be created.
Remove(string)
Attempts to remove a column by its name
.
public bool Remove(string name)
Parameters
name
stringName of the column to remove.
Returns
- bool
true when column was removed, otherwise false.
SetDefaultTypeDefinition(SqlColumnTypeDefinition)
Changes DefaultTypeDefinition value of this collection.
public SqlColumnBuilderCollection SetDefaultTypeDefinition(SqlColumnTypeDefinition definition)
Parameters
definition
SqlColumnTypeDefinitionValue to set.
Returns
Exceptions
- SqlObjectBuilderException
When
definition
is not valid.
TryGet(string)
Attempts to return a column with the provided name
.
[Pure]
public SqlColumnBuilder? TryGet(string name)
Parameters
name
stringName of the column to return.
Returns
- SqlColumnBuilder
Existing column or null when column does not exist.