Table of Contents

Class SqlObjectExtensions

Namespace
LfrlAnvil.Sql.Objects
Assembly
LfrlAnvil.Sql.Core.dll

Contains various extension methods related to SQL objects.

public static class SqlObjectExtensions
Inheritance
SqlObjectExtensions
Inherited Members

Methods

CreateDeleteFrom(SqlNewTableNode, Func<SqlNewTableNode, SqlConditionNode>?)

Creates a new SqlDeleteFromNode based on the provided table and a filter created from its primary key columns and matching parameters.

[Pure]
public static SqlDeleteFromNode CreateDeleteFrom(this SqlNewTableNode table, Func<SqlNewTableNode, SqlConditionNode>? filterExtension = null)

Parameters

table SqlNewTableNode

Table to create delete from for.

filterExtension Func<SqlNewTableNode, SqlConditionNode>

Optional delegate which allows to add additional filter to the primary key filter.

Returns

SqlDeleteFromNode

New SqlDeleteFromNode instance.

Exceptions

InvalidOperationException

When primary key is not defined or one of its columns is not a valid data field.

CreateDeleteFrom(ISqlTableBuilder, Func<SqlTableBuilderNode, SqlConditionNode>?)

Creates a new SqlDeleteFromNode based on the provided table and a filter created from its primary key columns and matching parameters.

[Pure]
public static SqlDeleteFromNode CreateDeleteFrom(this ISqlTableBuilder table, Func<SqlTableBuilderNode, SqlConditionNode>? filterExtension = null)

Parameters

table ISqlTableBuilder

Table to create delete from for.

filterExtension Func<SqlTableBuilderNode, SqlConditionNode>

Optional delegate which allows to add additional filter to the primary key filter.

Returns

SqlDeleteFromNode

New SqlDeleteFromNode instance.

Exceptions

SqlObjectBuilderException

When primary key builder does not exist.

CreateDeleteFrom(ISqlTable, Func<SqlTableNode, SqlConditionNode>?)

Creates a new SqlDeleteFromNode based on the provided table and a filter created from its primary key columns and matching parameters.

[Pure]
public static SqlDeleteFromNode CreateDeleteFrom(this ISqlTable table, Func<SqlTableNode, SqlConditionNode>? filterExtension = null)

Parameters

table ISqlTable

Table to create delete from for.

filterExtension Func<SqlTableNode, SqlConditionNode>

Optional delegate which allows to add additional filter to the primary key filter.

Returns

SqlDeleteFromNode

New SqlDeleteFromNode instance.

CreateInsertInto(SqlNewTableNode, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>?)

Creates a new SqlInsertIntoNode based on the provided table and its columns, where assigned values are matching parameters.

[Pure]
public static SqlInsertIntoNode CreateInsertInto(this SqlNewTableNode table, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>? valueOverride = null)

Parameters

table SqlNewTableNode

Table to create insert into for.

valueOverride Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>

Optional delegate which allows to either override the default matching parameter value or skip the column entirely.

Returns

SqlInsertIntoNode

New SqlInsertIntoNode instance.

Remarks

Computed and identity columns are always skipped.

CreateInsertInto(ISqlTableBuilder, Func<SqlColumnBuilderNode, SqlExpressionOverride>?)

Creates a new SqlInsertIntoNode based on the provided table and its columns, where assigned values are matching parameters.

[Pure]
public static SqlInsertIntoNode CreateInsertInto(this ISqlTableBuilder table, Func<SqlColumnBuilderNode, SqlExpressionOverride>? valueOverride = null)

Parameters

table ISqlTableBuilder

Table to create insert into for.

valueOverride Func<SqlColumnBuilderNode, SqlExpressionOverride>

Optional delegate which allows to either override the default matching parameter value or skip the column entirely.

Returns

SqlInsertIntoNode

New SqlInsertIntoNode instance.

Remarks

Computed and identity columns are always skipped.

CreateInsertInto(ISqlTable, Func<SqlColumnNode, SqlExpressionOverride>?)

Creates a new SqlInsertIntoNode based on the provided table and its columns, where assigned values are matching parameters.

[Pure]
public static SqlInsertIntoNode CreateInsertInto(this ISqlTable table, Func<SqlColumnNode, SqlExpressionOverride>? valueOverride = null)

Parameters

table ISqlTable

Table to create insert into for.

valueOverride Func<SqlColumnNode, SqlExpressionOverride>

Optional delegate which allows to either override the default matching parameter value or skip the column entirely.

Returns

SqlInsertIntoNode

New SqlInsertIntoNode instance.

Remarks

Computed and identity columns are always skipped.

CreateQuery(SqlNewTableNode, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlSelectionOverride>?, Func<SqlNewTableNode, IEnumerable<SqlSelectNode>>?, Func<SqlNewTableNode, IEnumerable<SqlOrderByNode>>?)

Creates a new SqlDataSourceQueryExpressionNode<TDataSourceNode> based on the provided table, where by default all columns are selected and ordering is done by primary key.

[Pure]
public static SqlDataSourceQueryExpressionNode<SqlSingleDataSourceNode<SqlNewTableNode>> CreateQuery(this SqlNewTableNode table, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlSelectionOverride>? selectionOverride = null, Func<SqlNewTableNode, IEnumerable<SqlSelectNode>>? additionalSelection = null, Func<SqlNewTableNode, IEnumerable<SqlOrderByNode>>? orderBy = null)

Parameters

table SqlNewTableNode

Table to create query for.

selectionOverride Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlSelectionOverride>

Optional delegate which allows to either override the default column selection or skip the column entirely.

additionalSelection Func<SqlNewTableNode, IEnumerable<SqlSelectNode>>

Optional delegate which allows to add custom selection.

orderBy Func<SqlNewTableNode, IEnumerable<SqlOrderByNode>>

Optional delegate which allows to override the default ordering by primary key.

Returns

SqlDataSourceQueryExpressionNode<SqlSingleDataSourceNode<SqlNewTableNode>>

New SqlDataSourceQueryExpressionNode<TDataSourceNode> instance.

CreateQuery(ISqlTableBuilder, Func<SqlColumnBuilderNode, SqlSelectionOverride>?, Func<SqlTableBuilderNode, IEnumerable<SqlSelectNode>>?, Func<SqlTableBuilderNode, IEnumerable<SqlOrderByNode>>?)

Creates a new SqlDataSourceQueryExpressionNode<TDataSourceNode> based on the provided table, where by default all columns are selected and ordering is done by primary key.

[Pure]
public static SqlDataSourceQueryExpressionNode<SqlSingleDataSourceNode<SqlTableBuilderNode>> CreateQuery(this ISqlTableBuilder table, Func<SqlColumnBuilderNode, SqlSelectionOverride>? selectionOverride = null, Func<SqlTableBuilderNode, IEnumerable<SqlSelectNode>>? additionalSelection = null, Func<SqlTableBuilderNode, IEnumerable<SqlOrderByNode>>? orderBy = null)

Parameters

table ISqlTableBuilder

Table to create query for.

selectionOverride Func<SqlColumnBuilderNode, SqlSelectionOverride>

Optional delegate which allows to either override the default column selection or skip the column entirely.

additionalSelection Func<SqlTableBuilderNode, IEnumerable<SqlSelectNode>>

Optional delegate which allows to add custom selection.

orderBy Func<SqlTableBuilderNode, IEnumerable<SqlOrderByNode>>

Optional delegate which allows to override the default ordering by primary key.

Returns

SqlDataSourceQueryExpressionNode<SqlSingleDataSourceNode<SqlTableBuilderNode>>

New SqlDataSourceQueryExpressionNode<TDataSourceNode> instance.

CreateQuery(ISqlTable, Func<SqlColumnNode, SqlSelectionOverride>?, Func<SqlTableNode, IEnumerable<SqlSelectNode>>?, Func<SqlTableNode, IEnumerable<SqlOrderByNode>>?)

Creates a new SqlDataSourceQueryExpressionNode<TDataSourceNode> based on the provided table, where by default all columns are selected and ordering is done by primary key.

[Pure]
public static SqlDataSourceQueryExpressionNode<SqlSingleDataSourceNode<SqlTableNode>> CreateQuery(this ISqlTable table, Func<SqlColumnNode, SqlSelectionOverride>? selectionOverride = null, Func<SqlTableNode, IEnumerable<SqlSelectNode>>? additionalSelection = null, Func<SqlTableNode, IEnumerable<SqlOrderByNode>>? orderBy = null)

Parameters

table ISqlTable

Table to create query for.

selectionOverride Func<SqlColumnNode, SqlSelectionOverride>

Optional delegate which allows to either override the default column selection or skip the column entirely.

additionalSelection Func<SqlTableNode, IEnumerable<SqlSelectNode>>

Optional delegate which allows to add custom selection.

orderBy Func<SqlTableNode, IEnumerable<SqlOrderByNode>>

Optional delegate which allows to override the default ordering by primary key.

Returns

SqlDataSourceQueryExpressionNode<SqlSingleDataSourceNode<SqlTableNode>>

New SqlDataSourceQueryExpressionNode<TDataSourceNode> instance.

CreateTempTable(ISqlTableBuilder, string, Func<ISqlColumnBuilder, SqlColumnDefinitionOverride>?, bool, Func<ISqlTableBuilder, SqlNewTableNode, SqlCreateTableConstraints>?)

Creates a new SqlCreateTableNode based on the provided table and its columns.

[Pure]
public static SqlCreateTableNode CreateTempTable(this ISqlTableBuilder table, string name, Func<ISqlColumnBuilder, SqlColumnDefinitionOverride>? columnOverride = null, bool ifNotExists = false, Func<ISqlTableBuilder, SqlNewTableNode, SqlCreateTableConstraints>? constraintsProvider = null)

Parameters

table ISqlTableBuilder

Table to create temporary table from.

name string

Name of the temporary table.

columnOverride Func<ISqlColumnBuilder, SqlColumnDefinitionOverride>

Optional delegate which allows to either override the default column definition or skip the column entirely.

ifNotExists bool

Specifies whether the temporary table should only be created if it does not already exist in DB. Equal to false by default.

constraintsProvider Func<ISqlTableBuilder, SqlNewTableNode, SqlCreateTableConstraints>

Optional SqlCreateTableConstraints provider.

Returns

SqlCreateTableNode

New SqlCreateTableNode instance.

Remarks

Default values, computations and identities are not included in default column definitions.

CreateTempTable(ISqlTable, string, Func<ISqlColumn, SqlColumnDefinitionOverride>?, bool, Func<ISqlTable, SqlNewTableNode, SqlCreateTableConstraints>?)

Creates a new SqlCreateTableNode based on the provided table and its columns.

[Pure]
public static SqlCreateTableNode CreateTempTable(this ISqlTable table, string name, Func<ISqlColumn, SqlColumnDefinitionOverride>? columnOverride = null, bool ifNotExists = false, Func<ISqlTable, SqlNewTableNode, SqlCreateTableConstraints>? constraintsProvider = null)

Parameters

table ISqlTable

Table to create temporary table from.

name string

Name of the temporary table.

columnOverride Func<ISqlColumn, SqlColumnDefinitionOverride>

Optional delegate which allows to either override the default column definition or skip the column entirely.

ifNotExists bool

Specifies whether the temporary table should only be created if it does not already exist in DB. Equal to false by default.

constraintsProvider Func<ISqlTable, SqlNewTableNode, SqlCreateTableConstraints>

Optional SqlCreateTableConstraints provider.

Returns

SqlCreateTableNode

New SqlCreateTableNode instance.

Remarks

Default values, computations and identities are not included in default column definitions.

CreateUpdate(SqlNewTableNode, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>?, Func<SqlNewTableNode, SqlConditionNode>?)

Creates a new SqlUpdateNode based on the provided table and its columns, where assigned values are matching parameters, and a filter created from its primary key columns and matching parameters.

[Pure]
public static SqlUpdateNode CreateUpdate(this SqlNewTableNode table, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>? valueOverride = null, Func<SqlNewTableNode, SqlConditionNode>? filterExtension = null)

Parameters

table SqlNewTableNode

Table to create update for.

valueOverride Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned matching parameter value or skip the column entirely from being updated.

filterExtension Func<SqlNewTableNode, SqlConditionNode>

Optional delegate which allows to add additional filter to the primary key filter.

Returns

SqlUpdateNode

New SqlUpdateNode instance.

Remarks

Computed, identity and primary key columns are always skipped from being updated.

Exceptions

InvalidOperationException

When primary key is not defined or one of its columns is not a valid data field.

CreateUpdate(ISqlTableBuilder, Func<SqlColumnBuilderNode, SqlExpressionOverride>?, Func<SqlTableBuilderNode, SqlConditionNode>?)

Creates a new SqlUpdateNode based on the provided table and its columns, where assigned values are matching parameters, and a filter created from its primary key columns and matching parameters.

[Pure]
public static SqlUpdateNode CreateUpdate(this ISqlTableBuilder table, Func<SqlColumnBuilderNode, SqlExpressionOverride>? valueOverride = null, Func<SqlTableBuilderNode, SqlConditionNode>? filterExtension = null)

Parameters

table ISqlTableBuilder

Table to create update for.

valueOverride Func<SqlColumnBuilderNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned matching parameter value or skip the column entirely from being updated.

filterExtension Func<SqlTableBuilderNode, SqlConditionNode>

Optional delegate which allows to add additional filter to the primary key filter.

Returns

SqlUpdateNode

New SqlUpdateNode instance.

Remarks

Computed, identity and primary key columns are always skipped from being updated.

Exceptions

SqlObjectBuilderException

When primary key builder does not exist.

CreateUpdate(ISqlTable, Func<SqlColumnNode, SqlExpressionOverride>?, Func<SqlTableNode, SqlConditionNode>?)

Creates a new SqlUpdateNode based on the provided table and its columns, where assigned values are matching parameters, and a filter created from its primary key columns and matching parameters.

[Pure]
public static SqlUpdateNode CreateUpdate(this ISqlTable table, Func<SqlColumnNode, SqlExpressionOverride>? valueOverride = null, Func<SqlTableNode, SqlConditionNode>? filterExtension = null)

Parameters

table ISqlTable

Table to create update for.

valueOverride Func<SqlColumnNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned matching parameter value or skip the column entirely from being updated.

filterExtension Func<SqlTableNode, SqlConditionNode>

Optional delegate which allows to add additional filter to the primary key filter.

Returns

SqlUpdateNode

New SqlUpdateNode instance.

Remarks

Computed, identity and primary key columns are always skipped from being updated.

CreateUpsert(SqlNewTableNode, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>?, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlDataFieldNode, SqlExpressionOverride>?, Func<SqlNewTableNode, SqlInternalRecordSetNode, SqlConditionNode>?)

Creates a new SqlUpsertNode based on the provided table and its columns, where assigned values are matching parameters.

[Pure]
public static SqlUpsertNode CreateUpsert(this SqlNewTableNode table, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>? insertValueOverride = null, Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlDataFieldNode, SqlExpressionOverride>? updateValueOverride = null, Func<SqlNewTableNode, SqlInternalRecordSetNode, SqlConditionNode>? updateFilter = null)

Parameters

table SqlNewTableNode

Table to create update for.

insertValueOverride Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned matching parameter value for the insert part or skip the column entirely from being inserted.

updateValueOverride Func<SqlColumnDefinitionNode, SqlRawDataFieldNode, SqlDataFieldNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned value for the update part or skip the column entirely from being updated.

updateFilter Func<SqlNewTableNode, SqlInternalRecordSetNode, SqlConditionNode>

Optional delegate which allows to set an additional update filter.

Returns

SqlUpsertNode

New SqlUpsertNode instance.

Remarks

Computed and identity columns are always skipped from being inserted. Computed, identity and primary key columns are always skipped from being updated.

Exceptions

InvalidOperationException

When primary key is not defined or one of its columns is not a valid data field.

CreateUpsert(ISqlTableBuilder, Func<SqlColumnBuilderNode, SqlExpressionOverride>?, Func<SqlColumnBuilderNode, SqlDataFieldNode, SqlExpressionOverride>?, Func<SqlTableBuilderNode, SqlInternalRecordSetNode, SqlConditionNode>?)

Creates a new SqlUpsertNode based on the provided table and its columns, where assigned values are matching parameters.

[Pure]
public static SqlUpsertNode CreateUpsert(this ISqlTableBuilder table, Func<SqlColumnBuilderNode, SqlExpressionOverride>? insertValueOverride = null, Func<SqlColumnBuilderNode, SqlDataFieldNode, SqlExpressionOverride>? updateValueOverride = null, Func<SqlTableBuilderNode, SqlInternalRecordSetNode, SqlConditionNode>? updateFilter = null)

Parameters

table ISqlTableBuilder

Table to create update for.

insertValueOverride Func<SqlColumnBuilderNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned matching parameter value for the insert part or skip the column entirely from being inserted.

updateValueOverride Func<SqlColumnBuilderNode, SqlDataFieldNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned value for the update part or skip the column entirely from being updated.

updateFilter Func<SqlTableBuilderNode, SqlInternalRecordSetNode, SqlConditionNode>

Optional delegate which allows to set an additional update filter.

Returns

SqlUpsertNode

New SqlUpsertNode instance.

Remarks

Computed and identity columns are always skipped from being inserted. Computed, identity and primary key columns are always skipped from being updated.

Exceptions

SqlObjectBuilderException

When primary key builder does not exist.

CreateUpsert(ISqlTable, Func<SqlColumnNode, SqlExpressionOverride>?, Func<SqlColumnNode, SqlDataFieldNode, SqlExpressionOverride>?, Func<SqlTableNode, SqlInternalRecordSetNode, SqlConditionNode>?)

Creates a new SqlUpsertNode based on the provided table and its columns, where assigned values are matching parameters.

[Pure]
public static SqlUpsertNode CreateUpsert(this ISqlTable table, Func<SqlColumnNode, SqlExpressionOverride>? insertValueOverride = null, Func<SqlColumnNode, SqlDataFieldNode, SqlExpressionOverride>? updateValueOverride = null, Func<SqlTableNode, SqlInternalRecordSetNode, SqlConditionNode>? updateFilter = null)

Parameters

table ISqlTable

Table to create update for.

insertValueOverride Func<SqlColumnNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned matching parameter value for the insert part or skip the column entirely from being inserted.

updateValueOverride Func<SqlColumnNode, SqlDataFieldNode, SqlExpressionOverride>

Optional delegate which allows to either override the default assigned value for the update part or skip the column entirely from being updated.

updateFilter Func<SqlTableNode, SqlInternalRecordSetNode, SqlConditionNode>

Optional delegate which allows to set an additional update filter.

Returns

SqlUpsertNode

New SqlUpsertNode instance.

Remarks

Computed and identity columns are always skipped from being inserted. Computed, identity and primary key columns are always skipped from being updated.