Search Results for

    Show / Hide Table of Contents
    View Source

    Class CreateForeignKeyBuilder

    Provides a builder for creating a foreign key constraint in a database migration.

    Inheritance
    object
    ExpressionBuilderBase<CreateForeignKeyExpression>
    Namespace: Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ForeignKey
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public class CreateForeignKeyBuilder : ExpressionBuilderBase<CreateForeignKeyExpression>, ICreateForeignKeyFromTableBuilder, ICreateForeignKeyForeignColumnBuilder, ICreateForeignKeyToTableBuilder, ICreateForeignKeyPrimaryColumnBuilder, ICreateForeignKeyCascadeBuilder, IFluentBuilder, IExecutableBuilder

    Constructors

    View Source

    CreateForeignKeyBuilder(CreateForeignKeyExpression)

    Initializes a new instance of the CreateForeignKeyBuilder class.

    Declaration
    public CreateForeignKeyBuilder(CreateForeignKeyExpression expression)
    Parameters
    Type Name Description
    CreateForeignKeyExpression expression

    The CreateForeignKeyExpression that defines the foreign key to be created.

    Methods

    View Source

    Do()

    Executes.

    Declaration
    public void Do()
    View Source

    ForeignColumn(string)

    Specifies the foreign column for the foreign key constraint.

    Declaration
    public ICreateForeignKeyToTableBuilder ForeignColumn(string column)
    Parameters
    Type Name Description
    string column

    The name of the foreign column.

    Returns
    Type Description
    ICreateForeignKeyToTableBuilder

    The builder to specify the table the foreign key references.

    View Source

    ForeignColumns(params string[])

    Specifies the foreign key columns for the foreign key constraint.

    Declaration
    public ICreateForeignKeyToTableBuilder ForeignColumns(params string[] columns)
    Parameters
    Type Name Description
    string[] columns

    The names of the foreign key columns.

    Returns
    Type Description
    ICreateForeignKeyToTableBuilder

    A builder to specify the referenced table for the foreign key.

    View Source

    FromTable(string)

    Sets the source table for the foreign key constraint.

    Declaration
    public ICreateForeignKeyForeignColumnBuilder FromTable(string table)
    Parameters
    Type Name Description
    string table

    The name of the source table.

    Returns
    Type Description
    ICreateForeignKeyForeignColumnBuilder

    An ICreateForeignKeyForeignColumnBuilder for further configuration.

    View Source

    OnDelete(Rule)

    Sets the action to take when a referenced row is deleted by specifying the delete rule for the foreign key constraint.

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

    The System.Data.Rule that defines the delete behavior (e.g., Cascade, SetNull, Restrict).

    Returns
    Type Description
    ICreateForeignKeyCascadeBuilder

    The current ICreateForeignKeyCascadeBuilder instance for method chaining.

    View Source

    OnDeleteOrUpdate(Rule)

    Configures the action to take when the referenced row is deleted or updated in the foreign key relationship.

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

    The referential action (such as Cascade, SetNull, or Restrict) to apply on delete or update.

    Returns
    Type Description
    IExecutableBuilder

    An IExecutableBuilder to continue building the migration expression.

    View Source

    OnUpdate(Rule)

    Sets the action to take when the referenced primary key is updated for this foreign key constraint.

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

    The update rule to apply (e.g., Cascade, SetNull, Restrict).

    Returns
    Type Description
    ICreateForeignKeyCascadeBuilder

    The current ICreateForeignKeyCascadeBuilder instance for method chaining.

    View Source

    PrimaryColumn(string)

    Specifies the primary (referenced) column for the foreign key constraint.

    Declaration
    public ICreateForeignKeyCascadeBuilder PrimaryColumn(string column)
    Parameters
    Type Name Description
    string column

    The name of the primary (referenced) column.

    Returns
    Type Description
    ICreateForeignKeyCascadeBuilder

    An ICreateForeignKeyCascadeBuilder to continue building the foreign key.

    View Source

    PrimaryColumns(params string[])

    Specifies the primary key columns for the foreign key.

    Declaration
    public ICreateForeignKeyCascadeBuilder PrimaryColumns(params string[] columns)
    Parameters
    Type Name Description
    string[] columns

    The names of the primary key columns.

    Returns
    Type Description
    ICreateForeignKeyCascadeBuilder

    An ICreateForeignKeyCascadeBuilder to continue building the foreign key.

    View Source

    ToTable(string)

    Specifies the table to which the foreign key will reference.

    Declaration
    public ICreateForeignKeyPrimaryColumnBuilder ToTable(string table)
    Parameters
    Type Name Description
    string table

    The name of the table to reference.

    Returns
    Type Description
    ICreateForeignKeyPrimaryColumnBuilder

    A builder to specify the primary column of the foreign key.

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