Search Results for

    Show / Hide Table of Contents
    View Source

    Class CreateColumnBuilder

    Provides a fluent builder for defining and configuring a new column as part of a database migration.

    Inheritance
    object
    ExpressionBuilderBase<CreateColumnExpression>
    ExpressionBuilderBase<CreateColumnExpression, ICreateColumnOptionBuilder>
    Namespace: Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.Column
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public class CreateColumnBuilder : ExpressionBuilderBase<CreateColumnExpression, ICreateColumnOptionBuilder>, ICreateColumnOnTableBuilder, ICreateColumnTypeBuilder, IColumnTypeBuilder<ICreateColumnOptionBuilder>, ICreateColumnOptionForeignKeyCascadeBuilder, ICreateColumnOptionBuilder, IColumnOptionBuilder<ICreateColumnOptionBuilder, ICreateColumnOptionForeignKeyCascadeBuilder>, IExecutableBuilder, IForeignKeyCascadeBuilder<ICreateColumnOptionBuilder, ICreateColumnOptionForeignKeyCascadeBuilder>, IFluentBuilder

    Constructors

    View Source

    CreateColumnBuilder(IMigrationContext, CreateColumnExpression)

    Initializes a new instance of the CreateColumnBuilder class.

    Declaration
    public CreateColumnBuilder(IMigrationContext context, CreateColumnExpression expression)
    Parameters
    Type Name Description
    IMigrationContext context

    The migration context.

    CreateColumnExpression expression

    The create column expression.

    Properties

    View Source

    CurrentForeignKey

    Gets or sets the current foreign key definition associated with the column.

    Declaration
    public ForeignKeyDefinition? CurrentForeignKey { get; set; }
    Property Value
    Type Description
    ForeignKeyDefinition

    Methods

    View Source

    Do()

    Executes the associated create column expression for the migration.

    Declaration
    public void Do()
    View Source

    ForeignKey()

    Specifies a foreign key constraint for the column referencing the given primary table and column.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder ForeignKey()
    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    An object for configuring cascade options on the foreign key constraint.

    View Source

    ForeignKey(string, string)

    Defines a foreign key constraint on the column referencing the specified primary table and column.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder ForeignKey(string primaryTableName, string primaryColumnName)
    Parameters
    Type Name Description
    string primaryTableName

    The name of the primary table that the foreign key references.

    string primaryColumnName

    The name of the primary column in the referenced table.

    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    A builder to specify foreign key cascade options.

    View Source

    ForeignKey(string, string, string)

    Defines a foreign key constraint on the column, using the specified constraint name, and referencing the given primary table and column.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder ForeignKey(string foreignKeyName, string primaryTableName, string primaryColumnName)
    Parameters
    Type Name Description
    string foreignKeyName

    The name of the foreign key constraint.

    string primaryTableName

    The name of the primary table referenced by the foreign key.

    string primaryColumnName

    The name of the primary column in the referenced table.

    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    An ICreateColumnOptionForeignKeyCascadeBuilder to specify cascade options for the foreign key.

    View Source

    ForeignKey(string?, string?, string, string)

    Defines a foreign key constraint for the column being created.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder ForeignKey(string? foreignKeyName, string? primaryTableSchema, string primaryTableName, string primaryColumnName)
    Parameters
    Type Name Description
    string foreignKeyName

    The name of the foreign key constraint. Can be null.

    string primaryTableSchema

    The schema of the primary table. Can be null.

    string primaryTableName

    The name of the primary table.

    string primaryColumnName

    The name of the primary column in the primary table.

    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    A builder to specify cascade options for the foreign key.

    View Source

    GetColumnForType()

    Returns the column definition associated with the current column expression.

    Declaration
    public override ColumnDefinition GetColumnForType()
    Returns
    Type Description
    ColumnDefinition

    The ColumnDefinition for the current column.

    View Source

    Identity()

    Configures the column as an identity column, meaning its value will be automatically generated and incremented by the database.

    Declaration
    public ICreateColumnOptionBuilder Identity()
    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder that can be used to further configure the column.

    View Source

    Indexed()

    Marks the column as indexed.

    Declaration
    public ICreateColumnOptionBuilder Indexed()
    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder to allow further configuration of the column.

    View Source

    Indexed(string?)

    Specifies that the column should be indexed with an optional index name.

    Declaration
    public ICreateColumnOptionBuilder Indexed(string? indexName)
    Parameters
    Type Name Description
    string indexName

    The name of the index to create. If null, a default name will be used.

    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder to continue building the column options.

    View Source

    NotNullable()

    Marks the column as not nullable.

    Declaration
    public ICreateColumnOptionBuilder NotNullable()
    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder to continue building the column.

    View Source

    Nullable()

    Marks the column as nullable.

    Declaration
    public ICreateColumnOptionBuilder Nullable()
    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder to continue building the column options.

    View Source

    OnDelete(Rule)

    Specifies the action to take when a referenced row in the foreign key is deleted.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder OnDelete(Rule rule)
    Parameters
    Type Name Description
    Rule rule

    The System.Data.Rule that determines the delete behavior for the foreign key constraint.

    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    An ICreateColumnOptionForeignKeyCascadeBuilder to continue configuring the column options.

    View Source

    OnDeleteOrUpdate(Rule)

    Sets the specified referential action rule to apply to both delete and update operations for the foreign key constraint on this column.

    Declaration
    public ICreateColumnOptionBuilder OnDeleteOrUpdate(Rule rule)
    Parameters
    Type Name Description
    Rule rule

    The System.Data.Rule to apply for both delete and update actions (e.g., Cascade, SetNull).

    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder that can be used to continue configuring the column options.

    View Source

    OnTable(string)

    Specifies the table name for the column being created.

    Declaration
    public ICreateColumnTypeBuilder OnTable(string name)
    Parameters
    Type Name Description
    string name

    The name of the table.

    Returns
    Type Description
    ICreateColumnTypeBuilder

    An ICreateColumnTypeBuilder to continue building the column.

    View Source

    OnUpdate(Rule)

    Sets the ON UPDATE rule for the foreign key constraint.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder OnUpdate(Rule rule)
    Parameters
    Type Name Description
    Rule rule

    The rule to apply on update.

    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    The current ICreateColumnOptionForeignKeyCascadeBuilder instance for chaining.

    View Source

    PrimaryKey()

    Marks the column as a primary key.

    Declaration
    public ICreateColumnOptionBuilder PrimaryKey()
    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder to allow further configuration of the column.

    View Source

    PrimaryKey(string)

    Marks the column as a primary key with the specified constraint name.

    Declaration
    public ICreateColumnOptionBuilder PrimaryKey(string primaryKeyName)
    Parameters
    Type Name Description
    string primaryKeyName

    The name of the primary key constraint.

    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder that can be used for further column configuration.

    View Source

    ReferencedBy(string, string)

    Specifies the foreign key relationship by referencing a foreign table and column.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder ReferencedBy(string foreignTableName, string foreignColumnName)
    Parameters
    Type Name Description
    string foreignTableName

    The name of the foreign table to reference.

    string foreignColumnName

    The name of the foreign column to reference.

    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    An ICreateColumnOptionForeignKeyCascadeBuilder to allow further configuration of the foreign key cascade options.

    View Source

    ReferencedBy(string, string, string)

    Specifies the foreign key relationship by referencing a foreign table and column with a specific foreign key name.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder ReferencedBy(string foreignKeyName, string foreignTableName, string foreignColumnName)
    Parameters
    Type Name Description
    string foreignKeyName

    The name of the foreign key constraint.

    string foreignTableName

    The name of the foreign table to reference.

    string foreignColumnName

    The name of the foreign column to reference.

    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    An ICreateColumnOptionForeignKeyCascadeBuilder to allow further configuration of the foreign key cascade options.

    View Source

    ReferencedBy(string?, string?, string, string)

    Defines a foreign key constraint referencing the specified table and column.

    Declaration
    public ICreateColumnOptionForeignKeyCascadeBuilder ReferencedBy(string? foreignKeyName, string? foreignTableSchema, string foreignTableName, string foreignColumnName)
    Parameters
    Type Name Description
    string foreignKeyName

    The name of the foreign key constraint. Can be null.

    string foreignTableSchema

    The schema of the foreign table. Can be null.

    string foreignTableName

    The name of the foreign table.

    string foreignColumnName

    The name of the foreign column.

    Returns
    Type Description
    ICreateColumnOptionForeignKeyCascadeBuilder

    An ICreateColumnOptionForeignKeyCascadeBuilder to specify cascade options.

    View Source

    Unique()

    Specifies that the column should have a unique constraint, ensuring all values in the column are distinct.

    Declaration
    public ICreateColumnOptionBuilder Unique()
    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder for further column option configuration.

    View Source

    Unique(string?)

    Specifies that the column should have a unique index.

    Declaration
    public ICreateColumnOptionBuilder Unique(string? indexName)
    Parameters
    Type Name Description
    string indexName

    The name of the unique index. If null, a default name will be used.

    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder to continue building the column options.

    View Source

    WithDefault(SystemMethods)

    Sets the default value of the column to the specified system method.

    Declaration
    public ICreateColumnOptionBuilder WithDefault(SystemMethods method)
    Parameters
    Type Name Description
    SystemMethods method

    The system method to use as the default value.

    Returns
    Type Description
    ICreateColumnOptionBuilder

    An object to continue building column options.

    View Source

    WithDefaultValue(object)

    Sets the default value for the column.

    Declaration
    public ICreateColumnOptionBuilder WithDefaultValue(object value)
    Parameters
    Type Name Description
    object value

    The default value to set for the column.

    Returns
    Type Description
    ICreateColumnOptionBuilder

    An ICreateColumnOptionBuilder to continue building the column options.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX