Class ColumnBase
The base class for column definitions
Implements
Inherited Members
Namespace: FluentMigrator.Runner.Generators.Base
Assembly: FluentMigrator.Runner.Core.dll
Syntax
public abstract class ColumnBase : IColumn
Constructors
| Edit this page View SourceColumnBase(ITypeMap, IQuoter)
Initializes a new instance of the ColumnBase class.
Declaration
protected ColumnBase(ITypeMap typeMap, IQuoter quoter)
Parameters
Type | Name | Description |
---|---|---|
ITypeMap | typeMap | The type map |
IQuoter | quoter | The quoter |
Properties
| Edit this page View SourceClauseOrder
Gets or sets the clause order
Declaration
protected IList<Func<ColumnDefinition, string>> ClauseOrder { get; set; }
Property Value
Type | Description |
---|---|
IList<Func<ColumnDefinition, string>> |
ForeignKeyConstraint
The default foreign key constraint format
Declaration
public virtual string ForeignKeyConstraint { get; }
Property Value
Type | Description |
---|---|
string |
Quoter
Gets the quoter
Declaration
protected IQuoter Quoter { get; }
Property Value
Type | Description |
---|---|
IQuoter |
Methods
| Edit this page View SourceAddPrimaryKeyConstraint(string, IEnumerable<ColumnDefinition>)
Creates the primary key constraint SQL fragment
Declaration
public virtual string AddPrimaryKeyConstraint(string tableName, IEnumerable<ColumnDefinition> primaryKeyColumns)
Parameters
Type | Name | Description |
---|---|---|
string | tableName | The table name |
IEnumerable<ColumnDefinition> | primaryKeyColumns | The primary key column definitions |
Returns
Type | Description |
---|---|
string | The SQL fragment |
FormatCascade(string, Rule)
Formats the foreign key cascading SQL fragment
Declaration
public virtual string FormatCascade(string onWhat, Rule rule)
Parameters
Type | Name | Description |
---|---|---|
string | onWhat | The action this cascade clause applies to (update or delete) |
Rule | rule | The cascade rule |
Returns
Type | Description |
---|---|
string | The formatted SQL fragment |
FormatCollation(ColumnDefinition)
Formats the collation of a text column
Declaration
protected virtual string FormatCollation(ColumnDefinition column)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition | column | The column definition |
Returns
Type | Description |
---|---|
string | The SQL fragment |
FormatDefaultValue(ColumnDefinition)
Formats the column default value
Declaration
protected virtual string FormatDefaultValue(ColumnDefinition column)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition | column | The column definition |
Returns
Type | Description |
---|---|
string | The formatted column default value |
FormatForeignKey(ForeignKeyDefinition, Func<ForeignKeyDefinition, string>)
Formats the foreign key SQL fragment optionally using a custom foreign key name generator
Declaration
public virtual string FormatForeignKey(ForeignKeyDefinition foreignKey, Func<ForeignKeyDefinition, string> fkNameGeneration)
Parameters
Type | Name | Description |
---|---|---|
ForeignKeyDefinition | foreignKey | The foreign key definition |
Func<ForeignKeyDefinition, string> | fkNameGeneration | The custom foreign key name generator |
Returns
Type | Description |
---|---|
string | The SQL fragment |
FormatIdentity(ColumnDefinition)
Formats the identity SQL fragment
Declaration
protected abstract string FormatIdentity(ColumnDefinition column)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition | column | The column definition |
Returns
Type | Description |
---|---|
string | The formatted identity SQL fragment |
FormatNullable(ColumnDefinition)
Formats the (not) null constraint
Declaration
protected virtual string FormatNullable(ColumnDefinition column)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition | column | The column definition |
Returns
Type | Description |
---|---|
string | The formatted (not) null constraint |
FormatPrimaryKey(ColumnDefinition)
Formats the primary key constraint directly attached to the column
Declaration
protected virtual string FormatPrimaryKey(ColumnDefinition column)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition | column | The column definition |
Returns
Type | Description |
---|---|
string | The primary key constraint SQL fragment |
FormatString(ColumnDefinition)
Formats the column name
Declaration
public virtual string FormatString(ColumnDefinition column)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition | column | The column definition |
Returns
Type | Description |
---|---|
string | The (probably) quoted column name |
FormatType(ColumnDefinition)
Formats the column type
Declaration
protected virtual string FormatType(ColumnDefinition column)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition | column | The column definition |
Returns
Type | Description |
---|---|
string | The formatted column type |
Generate(ColumnDefinition)
Generates the complete column definition SQL fragment
Declaration
public virtual string Generate(ColumnDefinition column)
Parameters
Type | Name | Description |
---|---|---|
ColumnDefinition | column | The column definition |
Returns
Type | Description |
---|---|
string | The SQL fragment |
Generate(IEnumerable<ColumnDefinition>, string)
Generate the SQL fragment for all column definitions
Declaration
public virtual string Generate(IEnumerable<ColumnDefinition> columns, string tableName)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ColumnDefinition> | columns | The column definitions |
string | tableName | The table name |
Returns
Type | Description |
---|---|
string | The SQL fragment |
GenerateForeignKeyName(ForeignKeyDefinition)
Generates the default foreign key name
Declaration
public virtual string GenerateForeignKeyName(ForeignKeyDefinition foreignKey)
Parameters
Type | Name | Description |
---|---|---|
ForeignKeyDefinition | foreignKey | The foreign key definition |
Returns
Type | Description |
---|---|
string | The SQL fragment |
GetPrimaryKeyConstraintName(IEnumerable<ColumnDefinition>, string)
Gets the name of the primary key constraint. Some Generators may need to override if the constraint name is limited
Declaration
protected virtual string GetPrimaryKeyConstraintName(IEnumerable<ColumnDefinition> primaryKeyColumns, string tableName)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ColumnDefinition> | primaryKeyColumns | The primary key columns |
string | tableName | The table name |
Returns
Type | Description |
---|---|
string | The constraint clause |
GetTypeMap(DbType, int, int)
Gets the formatted type from the type map
Declaration
[Obsolete]
protected string GetTypeMap(DbType value, int size, int precision)
Parameters
Type | Name | Description |
---|---|---|
DbType | value | The database type |
int | size | The size (or precision) |
int | precision | The precision (or scale) |
Returns
Type | Description |
---|---|
string | The formatted column type |
GetTypeMap(DbType, int?, int?)
Gets the formatted type from the type map
Declaration
protected string GetTypeMap(DbType value, int? size, int? precision)
Parameters
Type | Name | Description |
---|---|---|
DbType | value | The database type |
int? | size | The size (or precision) |
int? | precision | The precision (or scale) |
Returns
Type | Description |
---|---|
string | The formatted column type |
ShouldPrimaryKeysBeAddedSeparately(IEnumerable<ColumnDefinition>)
Returns a value indicating whether the primary key constraint should be added separately
Declaration
public virtual bool ShouldPrimaryKeysBeAddedSeparately(IEnumerable<ColumnDefinition> primaryKeyColumns)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ColumnDefinition> | primaryKeyColumns | The primary key column definitions |
Returns
Type | Description |
---|---|
bool |
|