Table of Contents

Class MySqlObjectExtensions

Namespace
LfrlAnvil.MySql.Extensions
Assembly
LfrlAnvil.MySql.dll

Contains various SqlObjectBuilder and SqlObject extension methods.

public static class MySqlObjectExtensions
Inheritance
MySqlObjectExtensions
Inherited Members

Remarks

MySqlDialect implementation.

Methods

CreateIndex(MySqlConstraintBuilderCollection, params SqlOrderByNode[])

Creates a new index builder with a default name.

public static MySqlIndexBuilder CreateIndex(this MySqlConstraintBuilderCollection constraints, params SqlOrderByNode[] columns)

Parameters

constraints MySqlConstraintBuilderCollection

Source collection.

columns SqlOrderByNode[]

Collection of columns that define the index.

Returns

MySqlIndexBuilder

New SqlIndexBuilder instance.

Exceptions

SqlObjectBuilderException

When index constraint could not be created.

CreateIndex(MySqlConstraintBuilderCollection, string, params SqlOrderByNode[])

Creates a new index builder.

public static MySqlIndexBuilder CreateIndex(this MySqlConstraintBuilderCollection constraints, string name, params SqlOrderByNode[] columns)

Parameters

constraints MySqlConstraintBuilderCollection

Source collection.

name string

Name of the index constraint.

columns SqlOrderByNode[]

Collection of columns that define the index.

Returns

MySqlIndexBuilder

New SqlIndexBuilder instance.

Exceptions

SqlObjectBuilderException

When index constraint could not be created.

CreateUniqueIndex(MySqlConstraintBuilderCollection, params SqlOrderByNode[])

Creates a new unique index builder with a default name.

public static MySqlIndexBuilder CreateUniqueIndex(this MySqlConstraintBuilderCollection constraints, params SqlOrderByNode[] columns)

Parameters

constraints MySqlConstraintBuilderCollection

Source collection.

columns SqlOrderByNode[]

Collection of columns that define the index.

Returns

MySqlIndexBuilder

New SqlIndexBuilder instance.

Exceptions

SqlObjectBuilderException

When index constraint could not be created.

CreateUniqueIndex(MySqlConstraintBuilderCollection, string, params SqlOrderByNode[])

Creates a new unique index builder.

public static MySqlIndexBuilder CreateUniqueIndex(this MySqlConstraintBuilderCollection constraints, string name, params SqlOrderByNode[] columns)

Parameters

constraints MySqlConstraintBuilderCollection

Source collection.

name string

Name of the index constraint.

columns SqlOrderByNode[]

Collection of columns that define the index.

Returns

MySqlIndexBuilder

New SqlIndexBuilder instance.

Exceptions

SqlObjectBuilderException

When index constraint could not be created.

ForMySql(ISqlCheckBuilder, Action<MySqlCheckBuilder>)

Invokes the provided action only when the builder is an instance of MySqlCheckBuilder type.

public static ISqlCheckBuilder ForMySql(this ISqlCheckBuilder builder, Action<MySqlCheckBuilder> action)

Parameters

builder ISqlCheckBuilder

Source builder.

action Action<MySqlCheckBuilder>

Action to invoke.

Returns

ISqlCheckBuilder

builder.

ForMySql(ISqlColumnBuilder, Action<MySqlColumnBuilder>)

Invokes the provided action only when the builder is an instance of MySqlColumnBuilder type.

public static ISqlColumnBuilder ForMySql(this ISqlColumnBuilder builder, Action<MySqlColumnBuilder> action)

Parameters

builder ISqlColumnBuilder

Source builder.

action Action<MySqlColumnBuilder>

Action to invoke.

Returns

ISqlColumnBuilder

builder.

ForMySql(ISqlDatabaseBuilder, Action<MySqlDatabaseBuilder>)

Invokes the provided action only when the builder is an instance of MySqlDatabaseBuilder type.

public static ISqlDatabaseBuilder ForMySql(this ISqlDatabaseBuilder builder, Action<MySqlDatabaseBuilder> action)

Parameters

builder ISqlDatabaseBuilder

Source builder.

action Action<MySqlDatabaseBuilder>

Action to invoke.

Returns

ISqlDatabaseBuilder

builder.

ForMySql(ISqlForeignKeyBuilder, Action<MySqlForeignKeyBuilder>)

Invokes the provided action only when the builder is an instance of MySqlForeignKeyBuilder type.

public static ISqlForeignKeyBuilder ForMySql(this ISqlForeignKeyBuilder builder, Action<MySqlForeignKeyBuilder> action)

Parameters

builder ISqlForeignKeyBuilder

Source builder.

action Action<MySqlForeignKeyBuilder>

Action to invoke.

Returns

ISqlForeignKeyBuilder

builder.

ForMySql(ISqlIndexBuilder, Action<MySqlIndexBuilder>)

Invokes the provided action only when the builder is an instance of MySqlIndexBuilder type.

public static ISqlIndexBuilder ForMySql(this ISqlIndexBuilder builder, Action<MySqlIndexBuilder> action)

Parameters

builder ISqlIndexBuilder

Source builder.

action Action<MySqlIndexBuilder>

Action to invoke.

Returns

ISqlIndexBuilder

builder.

ForMySql(ISqlPrimaryKeyBuilder, Action<MySqlPrimaryKeyBuilder>)

Invokes the provided action only when the builder is an instance of MySqlPrimaryKeyBuilder type.

public static ISqlPrimaryKeyBuilder ForMySql(this ISqlPrimaryKeyBuilder builder, Action<MySqlPrimaryKeyBuilder> action)

Parameters

builder ISqlPrimaryKeyBuilder

Source builder.

action Action<MySqlPrimaryKeyBuilder>

Action to invoke.

Returns

ISqlPrimaryKeyBuilder

builder.

ForMySql(ISqlSchemaBuilder, Action<MySqlSchemaBuilder>)

Invokes the provided action only when the builder is an instance of MySqlSchemaBuilder type.

public static ISqlSchemaBuilder ForMySql(this ISqlSchemaBuilder builder, Action<MySqlSchemaBuilder> action)

Parameters

builder ISqlSchemaBuilder

Source builder.

action Action<MySqlSchemaBuilder>

Action to invoke.

Returns

ISqlSchemaBuilder

builder.

ForMySql(ISqlTableBuilder, Action<MySqlTableBuilder>)

Invokes the provided action only when the builder is an instance of MySqlTableBuilder type.

public static ISqlTableBuilder ForMySql(this ISqlTableBuilder builder, Action<MySqlTableBuilder> action)

Parameters

builder ISqlTableBuilder

Source builder.

action Action<MySqlTableBuilder>

Action to invoke.

Returns

ISqlTableBuilder

builder.

ForMySql(ISqlViewBuilder, Action<MySqlViewBuilder>)

Invokes the provided action only when the builder is an instance of MySqlViewBuilder type.

public static ISqlViewBuilder ForMySql(this ISqlViewBuilder builder, Action<MySqlViewBuilder> action)

Parameters

builder ISqlViewBuilder

Source builder.

action Action<MySqlViewBuilder>

Action to invoke.

Returns

ISqlViewBuilder

builder.

SetDefaultValue<T>(MySqlColumnBuilder, T?)

Changes DefaultValue value of the provided column.

public static MySqlColumnBuilder SetDefaultValue<T>(this MySqlColumnBuilder column, T? value) where T : struct

Parameters

column MySqlColumnBuilder

Source column.

value T?

Value to set.

Returns

MySqlColumnBuilder

column.

Type Parameters

T

Value type.

Exceptions

SqlObjectBuilderException

When default value cannot be changed.

SetDefaultValue<T>(MySqlColumnBuilder, T?)

Changes DefaultValue value of the provided column.

public static MySqlColumnBuilder SetDefaultValue<T>(this MySqlColumnBuilder column, T? value) where T : notnull

Parameters

column MySqlColumnBuilder

Source column.

value T

Value to set.

Returns

MySqlColumnBuilder

column.

Type Parameters

T

Value type.

Exceptions

SqlObjectBuilderException

When default value cannot be changed.

SetFilter(MySqlIndexBuilder, Func<SqlTableBuilderNode, SqlConditionNode?>)

Changes Filter value of the provided index.

public static MySqlIndexBuilder SetFilter(this MySqlIndexBuilder index, Func<SqlTableBuilderNode, SqlConditionNode?> filter)

Parameters

index MySqlIndexBuilder

Source index.

filter Func<SqlTableBuilderNode, SqlConditionNode>

Value to set.

Returns

MySqlIndexBuilder

index.

Exceptions

SqlObjectBuilderException

When filter cannot be changed.

SetPrimaryKey(MySqlConstraintBuilderCollection, params SqlOrderByNode[])

Creates a new unique index builder with a default name and sets a new primary key builder with a default name based on that index.

public static MySqlPrimaryKeyBuilder SetPrimaryKey(this MySqlConstraintBuilderCollection constraints, params SqlOrderByNode[] columns)

Parameters

constraints MySqlConstraintBuilderCollection

Source collection.

columns SqlOrderByNode[]

Collection of columns that define the underlying index.

Returns

MySqlPrimaryKeyBuilder

New SqlPrimaryKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When unique index constraint or primary key constraint could not be created.

SetPrimaryKey(MySqlConstraintBuilderCollection, string, params SqlOrderByNode[])

Creates a new unique index builder with a default name and sets a new primary key builder based on that index.

public static MySqlPrimaryKeyBuilder SetPrimaryKey(this MySqlConstraintBuilderCollection constraints, string name, params SqlOrderByNode[] columns)

Parameters

constraints MySqlConstraintBuilderCollection

Source collection.

name string

Name of the primary key constraint.

columns SqlOrderByNode[]

Collection of columns that define the underlying index.

Returns

MySqlPrimaryKeyBuilder

New SqlPrimaryKeyBuilder instance.

Exceptions

SqlObjectBuilderException

When unique index constraint or primary key constraint could not be created.

SetType(MySqlColumnBuilder, MySqlDataType)

Changes TypeDefinition value of the provided column.

public static MySqlColumnBuilder SetType(this MySqlColumnBuilder column, MySqlDataType dataType)

Parameters

column MySqlColumnBuilder

Source column.

dataType MySqlDataType

MySqlDataType to use for retrieving a default type definition associated with it.

Returns

MySqlColumnBuilder

column.

Remarks

Changing the type will reset the DefaultValue to null.

Exceptions

SqlObjectBuilderException

When type definition cannot be changed.

SetType(MySqlColumnBuilder, Type)

Changes TypeDefinition value of the provided column.

public static MySqlColumnBuilder SetType(this MySqlColumnBuilder column, Type type)

Parameters

column MySqlColumnBuilder

Source column.

type Type

Runtime type to use for retrieving a type definition associated with it.

Returns

MySqlColumnBuilder

column.

Remarks

Changing the type will reset the DefaultValue to null.

Exceptions

SqlObjectBuilderException

When type definition cannot be changed.

SetType<T>(MySqlColumnBuilder)

Changes TypeDefinition value of the provided column.

public static MySqlColumnBuilder SetType<T>(this MySqlColumnBuilder column)

Parameters

column MySqlColumnBuilder

Source column.

Returns

MySqlColumnBuilder

column.

Type Parameters

T

Runtime type to use for retrieving a type definition associated with it.

Remarks

Changing the type will reset the DefaultValue to null.

Exceptions

SqlObjectBuilderException

When type definition cannot be changed.