Table of Contents

Class BasicSqlBuilder

Namespace
LinqToDB.SqlProvider
Assembly
linq2db.dll
public abstract class BasicSqlBuilder : ISqlBuilder
Inheritance
BasicSqlBuilder
Implements
Derived
Extension Methods

Constructors

BasicSqlBuilder(IDataProvider?, MappingSchema, DataOptions, ISqlOptimizer, SqlProviderFlags)

protected BasicSqlBuilder(IDataProvider? provider, MappingSchema mappingSchema, DataOptions dataOptions, ISqlOptimizer sqlOptimizer, SqlProviderFlags sqlProviderFlags)

Parameters

provider IDataProvider
mappingSchema MappingSchema
dataOptions DataOptions
sqlOptimizer ISqlOptimizer
sqlProviderFlags SqlProviderFlags

BasicSqlBuilder(BasicSqlBuilder)

protected BasicSqlBuilder(BasicSqlBuilder parentBuilder)

Parameters

parentBuilder BasicSqlBuilder

Fields

BuildExpressionContext

protected object? BuildExpressionContext

Field Value

object

BuildStep

protected BasicSqlBuilder.Step BuildStep

Field Value

BasicSqlBuilder.Step

DataProvider

protected IDataProvider? DataProvider

Field Value

IDataProvider

EndLine

protected static readonly char[] EndLine

Field Value

char[]

Indent

protected int Indent

Field Value

int

SkipAlias

protected bool SkipAlias

Field Value

bool

SqlOptimizer

protected ISqlOptimizer SqlOptimizer

Field Value

ISqlOptimizer

Statement

protected SqlStatement Statement

Field Value

SqlStatement

Properties

Comma

End-of-line comma separator. Default value:

","
protected virtual string Comma { get; }

Property Value

string

CteFirst

Identifies CTE clause location:

  • CteFirst = true (default): WITH clause goes first in query
  • CteFirst = false: WITH clause goes before SELECT
public virtual bool CteFirst { get; }

Property Value

bool

DataOptions

public DataOptions DataOptions { get; }

Property Value

DataOptions

DeletedOutputTable

protected virtual string DeletedOutputTable { get; }

Property Value

string

FakeTable

If IsValuesSyntaxSupported set to false and provider doesn't support SELECTs without FROM clause, this property should contain name of table (or equivalent SQL) with single record. IMPORTANT: as this property could return SQL, we don't escape it, so it should contain only valid SQL/identifiers.

protected virtual string? FakeTable { get; }

Property Value

string

FakeTableSchema

If IsValuesSyntaxSupported set to false and provider doesn't support SELECTs without FROM clause, this property could contain name of schema for table with single record. Returned name should be already escaped if escaping required.

protected virtual string? FakeTableSchema { get; }

Property Value

string

InlineComma

Inline comma separator. Default value:

", "
protected virtual string InlineComma { get; }

Property Value

string

InsertedOutputTable

protected virtual string InsertedOutputTable { get; }

Property Value

string

IsCteColumnListSupported

protected virtual bool IsCteColumnListSupported { get; }

Property Value

bool

IsEmptyValuesSourceSupported

If true, builder will generate command for empty enumerable source; Otherwise exception will be generated.

protected virtual bool IsEmptyValuesSourceSupported { get; }

Property Value

bool

IsNestedJoinParenthesisRequired

public virtual bool IsNestedJoinParenthesisRequired { get; }

Property Value

bool

IsNestedJoinSupported

public virtual bool IsNestedJoinSupported { get; }

Property Value

bool

IsRecursiveCteKeywordRequired

protected virtual bool IsRecursiveCteKeywordRequired { get; }

Property Value

bool

IsValuesSyntaxSupported

If true, provider supports list of VALUES as a source element of merge command.

protected virtual bool IsValuesSyntaxSupported { get; }

Property Value

bool

MappingSchema

public MappingSchema MappingSchema { get; }

Property Value

MappingSchema

Name

public virtual string Name { get; }

Property Value

string

OffsetFirst

protected virtual bool OffsetFirst { get; }

Property Value

bool

OpenParens

End-of-line open parentheses element. Default value:

"("
protected virtual string OpenParens { get; }

Property Value

string

OptimizationContext

public OptimizationContext OptimizationContext { get; protected set; }

Property Value

OptimizationContext

OutputKeyword

protected virtual string OutputKeyword { get; }

Property Value

string

QueryName

public string? QueryName { get; set; }

Property Value

string

RequiresConstantColumnAliases

If true, provider require column aliases for each column. E.g. as table_alias (column_alias1, column_alias2).

protected virtual bool RequiresConstantColumnAliases { get; }

Property Value

bool

SkipFirst

protected virtual bool SkipFirst { get; }

Property Value

bool

SkipFormat

protected virtual string? SkipFormat { get; }

Property Value

string

SqlProviderFlags

public SqlProviderFlags SqlProviderFlags { get; }

Property Value

SqlProviderFlags

StringBuilder

public StringBuilder StringBuilder { get; set; }

Property Value

StringBuilder

SupportsBooleanInColumn

protected virtual bool SupportsBooleanInColumn { get; }

Property Value

bool

SupportsColumnAliasesInSource

If true, provider supports column aliases specification after table alias. E.g. as table_alias (column_alias1, column_alias2).

protected virtual bool SupportsColumnAliasesInSource { get; }

Property Value

bool

SupportsNullInColumn

protected virtual bool SupportsNullInColumn { get; }

Property Value

bool

TableIDs

public Dictionary<string, TableIDInfo>? TableIDs { get; set; }

Property Value

Dictionary<string, TableIDInfo>

TablePath

public string? TablePath { get; set; }

Property Value

string

TakePercent

protected virtual string TakePercent { get; }

Property Value

string

TakeTies

protected virtual string TakeTies { get; }

Property Value

string

UpdateKeyword

protected virtual string UpdateKeyword { get; }

Property Value

string

UpdateSetKeyword

protected virtual string UpdateSetKeyword { get; }

Property Value

string

ValueToSqlConverter

protected ValueToSqlConverter ValueToSqlConverter { get; }

Property Value

ValueToSqlConverter

WrapJoinCondition

True if it is needed to wrap join condition with ()

public virtual bool WrapJoinCondition { get; }

Property Value

bool

Examples

INNER JOIN Table2 t2 ON (t1.Value = t2.Value)

Methods

AlternativeGetSelectedColumns(SelectQuery, IEnumerable<SqlColumn>)

protected IEnumerable<SqlColumn> AlternativeGetSelectedColumns(SelectQuery selectQuery, IEnumerable<SqlColumn> columns)

Parameters

selectQuery SelectQuery
columns IEnumerable<SqlColumn>

Returns

IEnumerable<SqlColumn>

AppendIndent()

protected StringBuilder AppendIndent()

Returns

StringBuilder

ApplyQueryHints(string, IReadOnlyCollection<string>)

public string ApplyQueryHints(string sqlText, IReadOnlyCollection<string> queryHints)

Parameters

sqlText string
queryHints IReadOnlyCollection<string>

Returns

string

BuildAlterDeleteClause(SqlDeleteStatement)

protected virtual void BuildAlterDeleteClause(SqlDeleteStatement deleteStatement)

Parameters

deleteStatement SqlDeleteStatement

BuildBinaryExpression(SqlBinaryExpression)

protected virtual void BuildBinaryExpression(SqlBinaryExpression expr)

Parameters

expr SqlBinaryExpression

BuildColumnExpression(SelectQuery?, ISqlExpression, string?, ref bool)

protected virtual void BuildColumnExpression(SelectQuery? selectQuery, ISqlExpression expr, string? alias, ref bool addAlias)

Parameters

selectQuery SelectQuery
expr ISqlExpression
alias string
addAlias bool

BuildColumns(SelectQuery)

protected virtual void BuildColumns(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildCommand(SqlStatement, int)

protected virtual void BuildCommand(SqlStatement statement, int commandNumber)

Parameters

statement SqlStatement
commandNumber int

BuildCreateTableCommand(SqlTable)

protected virtual void BuildCreateTableCommand(SqlTable table)

Parameters

table SqlTable

BuildCreateTableFieldType(SqlField)

protected virtual void BuildCreateTableFieldType(SqlField field)

Parameters

field SqlField

BuildCreateTableIdentityAttribute1(SqlField)

protected virtual void BuildCreateTableIdentityAttribute1(SqlField field)

Parameters

field SqlField

BuildCreateTableIdentityAttribute2(SqlField)

protected virtual void BuildCreateTableIdentityAttribute2(SqlField field)

Parameters

field SqlField

BuildCreateTableNullAttribute(SqlField, DefaultNullable)

protected virtual void BuildCreateTableNullAttribute(SqlField field, DefaultNullable defaultNullable)

Parameters

field SqlField
defaultNullable DefaultNullable

BuildCreateTablePrimaryKey(SqlCreateTableStatement, string, IEnumerable<string>)

protected virtual void BuildCreateTablePrimaryKey(SqlCreateTableStatement createTable, string pkName, IEnumerable<string> fieldNames)

Parameters

createTable SqlCreateTableStatement
pkName string
fieldNames IEnumerable<string>

BuildCreateTableStatement(SqlCreateTableStatement)

protected virtual void BuildCreateTableStatement(SqlCreateTableStatement createTable)

Parameters

createTable SqlCreateTableStatement

BuildCteBody(SelectQuery)

protected virtual void BuildCteBody(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildDataType(SqlDataType, bool, bool)

protected void BuildDataType(SqlDataType type, bool forCreateTable, bool canBeNull)

Parameters

type SqlDataType
forCreateTable bool
canBeNull bool

Type could store NULL values (could be used for column table type generation or for databases with explicit typee nullability like ClickHouse).

BuildDataType(StringBuilder, SqlDataType)

Appends an SqlDataType's String to a provided StringBuilder

public StringBuilder BuildDataType(StringBuilder sb, SqlDataType dataType)

Parameters

sb StringBuilder
dataType SqlDataType

Returns

StringBuilder

The stringbuilder with the type information appended.

BuildDataTypeFromDataType(SqlDataType, bool, bool)

protected virtual void BuildDataTypeFromDataType(SqlDataType type, bool forCreateTable, bool canBeNull)

Parameters

type SqlDataType
forCreateTable bool
canBeNull bool

Type could store NULL values (could be used for column table type generation or for databases with explicit typee nullability like ClickHouse).

BuildDeleteClause(SqlDeleteStatement)

protected virtual void BuildDeleteClause(SqlDeleteStatement deleteStatement)

Parameters

deleteStatement SqlDeleteStatement

BuildDeleteFromClause(SqlDeleteStatement)

protected virtual void BuildDeleteFromClause(SqlDeleteStatement deleteStatement)

Parameters

deleteStatement SqlDeleteStatement

BuildDeleteQuery(SqlDeleteStatement)

protected virtual void BuildDeleteQuery(SqlDeleteStatement deleteStatement)

Parameters

deleteStatement SqlDeleteStatement

BuildDeleteQuery2(SqlDeleteStatement)

protected void BuildDeleteQuery2(SqlDeleteStatement deleteStatement)

Parameters

deleteStatement SqlDeleteStatement

BuildDropTableStatement(SqlDropTableStatement)

protected virtual void BuildDropTableStatement(SqlDropTableStatement dropTable)

Parameters

dropTable SqlDropTableStatement

BuildDropTableStatementIfExists(SqlDropTableStatement)

protected void BuildDropTableStatementIfExists(SqlDropTableStatement dropTable)

Parameters

dropTable SqlDropTableStatement

BuildEmptyInsert(SqlInsertClause)

protected virtual void BuildEmptyInsert(SqlInsertClause insertClause)

Parameters

insertClause SqlInsertClause

BuildEmptyValues(SqlValuesTable)

protected void BuildEmptyValues(SqlValuesTable valuesTable)

Parameters

valuesTable SqlValuesTable

BuildEndCreateTableStatement(SqlCreateTableStatement)

protected virtual void BuildEndCreateTableStatement(SqlCreateTableStatement createTable)

Parameters

createTable SqlCreateTableStatement

BuildExprExprPredicate(ExprExpr)

protected virtual void BuildExprExprPredicate(SqlPredicate.ExprExpr expr)

Parameters

expr SqlPredicate.ExprExpr

BuildExprExprPredicateOperator(ExprExpr)

protected virtual void BuildExprExprPredicateOperator(SqlPredicate.ExprExpr expr)

Parameters

expr SqlPredicate.ExprExpr

BuildExpression(ISqlExpression)

protected StringBuilder BuildExpression(ISqlExpression expr)

Parameters

expr ISqlExpression

Returns

StringBuilder

BuildExpression(ISqlExpression, bool, bool, bool)

public void BuildExpression(ISqlExpression expr, bool buildTableName, bool checkParentheses, bool throwExceptionIfTableNotFound = true)

Parameters

expr ISqlExpression
buildTableName bool
checkParentheses bool
throwExceptionIfTableNotFound bool

BuildExpression(ISqlExpression, bool, bool, string?, ref bool, bool)

protected virtual StringBuilder BuildExpression(ISqlExpression expr, bool buildTableName, bool checkParentheses, string? alias, ref bool addAlias, bool throwExceptionIfTableNotFound = true)

Parameters

expr ISqlExpression
buildTableName bool
checkParentheses bool
alias string
addAlias bool
throwExceptionIfTableNotFound bool

Returns

StringBuilder

BuildExpression(int, ISqlExpression)

protected void BuildExpression(int precedence, ISqlExpression expr)

Parameters

precedence int
expr ISqlExpression

BuildExpressionForOrderBy(ISqlExpression)

protected virtual void BuildExpressionForOrderBy(ISqlExpression expr)

Parameters

expr ISqlExpression

BuildFakeTableName()

protected virtual bool BuildFakeTableName()

Returns

bool

BuildFieldTableAlias(SqlField)

Used to disable field table name (alias) generation.

protected virtual bool BuildFieldTableAlias(SqlField field)

Parameters

field SqlField

Returns

bool

BuildFromClause(SqlStatement, SelectQuery)

protected virtual void BuildFromClause(SqlStatement statement, SelectQuery selectQuery)

Parameters

statement SqlStatement
selectQuery SelectQuery

BuildFromExtensions(SelectQuery)

protected virtual void BuildFromExtensions(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildFunction(SqlFunction)

protected virtual void BuildFunction(SqlFunction func)

Parameters

func SqlFunction

BuildGetIdentity(SqlInsertClause)

protected virtual void BuildGetIdentity(SqlInsertClause insertClause)

Parameters

insertClause SqlInsertClause

BuildGroupByBody(GroupingType, List<ISqlExpression>)

protected virtual void BuildGroupByBody(GroupingType groupingType, List<ISqlExpression> items)

Parameters

groupingType GroupingType
items List<ISqlExpression>

BuildGroupByClause(SelectQuery)

protected virtual void BuildGroupByClause(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildHavingClause(SelectQuery)

protected virtual void BuildHavingClause(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildInsertClause(SqlStatement, SqlInsertClause, bool)

protected void BuildInsertClause(SqlStatement statement, SqlInsertClause insertClause, bool addAlias)

Parameters

statement SqlStatement
insertClause SqlInsertClause
addAlias bool

BuildInsertClause(SqlStatement, SqlInsertClause, string?, bool, bool)

protected virtual void BuildInsertClause(SqlStatement statement, SqlInsertClause insertClause, string? insertText, bool appendTableName, bool addAlias)

Parameters

statement SqlStatement
insertClause SqlInsertClause
insertText string
appendTableName bool
addAlias bool

BuildInsertOrUpdateQuery(SqlInsertOrUpdateStatement)

protected virtual void BuildInsertOrUpdateQuery(SqlInsertOrUpdateStatement insertOrUpdate)

Parameters

insertOrUpdate SqlInsertOrUpdateStatement

BuildInsertOrUpdateQueryAsMerge(SqlInsertOrUpdateStatement, string?)

protected virtual void BuildInsertOrUpdateQueryAsMerge(SqlInsertOrUpdateStatement insertOrUpdate, string? fromDummyTable)

Parameters

insertOrUpdate SqlInsertOrUpdateStatement
fromDummyTable string

BuildInsertOrUpdateQueryAsUpdateInsert(SqlInsertOrUpdateStatement)

protected void BuildInsertOrUpdateQueryAsUpdateInsert(SqlInsertOrUpdateStatement insertOrUpdate)

Parameters

insertOrUpdate SqlInsertOrUpdateStatement

BuildInsertQuery(SqlStatement, SqlInsertClause, bool)

protected virtual void BuildInsertQuery(SqlStatement statement, SqlInsertClause insertClause, bool addAlias)

Parameters

statement SqlStatement
insertClause SqlInsertClause
addAlias bool

BuildInsertQuery2(SqlStatement, SqlInsertClause, bool)

protected void BuildInsertQuery2(SqlStatement statement, SqlInsertClause insertClause, bool addAlias)

Parameters

statement SqlStatement
insertClause SqlInsertClause
addAlias bool

BuildIsDistinctPredicate(IsDistinct)

protected virtual void BuildIsDistinctPredicate(SqlPredicate.IsDistinct expr)

Parameters

expr SqlPredicate.IsDistinct

BuildIsDistinctPredicateFallback(IsDistinct)

protected void BuildIsDistinctPredicateFallback(SqlPredicate.IsDistinct expr)

Parameters

expr SqlPredicate.IsDistinct

BuildJoinTable(SelectQuery, SqlJoinedTable, ref int)

protected void BuildJoinTable(SelectQuery selectQuery, SqlJoinedTable join, ref int joinCounter)

Parameters

selectQuery SelectQuery
join SqlJoinedTable
joinCounter int

BuildJoinType(SqlJoinedTable, SqlSearchCondition)

protected virtual bool BuildJoinType(SqlJoinedTable join, SqlSearchCondition condition)

Parameters

join SqlJoinedTable
condition SqlSearchCondition

Returns

bool

BuildLikePredicate(Like)

protected virtual void BuildLikePredicate(SqlPredicate.Like predicate)

Parameters

predicate SqlPredicate.Like

BuildMergeInto(SqlMergeStatement)

protected virtual void BuildMergeInto(SqlMergeStatement merge)

Parameters

merge SqlMergeStatement

BuildMergeOn(SqlMergeStatement)

protected virtual void BuildMergeOn(SqlMergeStatement mergeStatement)

Parameters

mergeStatement SqlMergeStatement

BuildMergeOperationDelete(SqlMergeOperationClause)

protected virtual void BuildMergeOperationDelete(SqlMergeOperationClause operation)

Parameters

operation SqlMergeOperationClause

BuildMergeOperationDeleteBySource(SqlMergeOperationClause)

protected virtual void BuildMergeOperationDeleteBySource(SqlMergeOperationClause operation)

Parameters

operation SqlMergeOperationClause

BuildMergeOperationInsert(SqlMergeOperationClause)

protected virtual void BuildMergeOperationInsert(SqlMergeOperationClause operation)

Parameters

operation SqlMergeOperationClause

BuildMergeOperationUpdate(SqlMergeOperationClause)

protected virtual void BuildMergeOperationUpdate(SqlMergeOperationClause operation)

Parameters

operation SqlMergeOperationClause

BuildMergeOperationUpdateBySource(SqlMergeOperationClause)

protected virtual void BuildMergeOperationUpdateBySource(SqlMergeOperationClause operation)

Parameters

operation SqlMergeOperationClause

BuildMergeOperationUpdateWithDelete(SqlMergeOperationClause)

protected virtual void BuildMergeOperationUpdateWithDelete(SqlMergeOperationClause operation)

Parameters

operation SqlMergeOperationClause

BuildMergeSourceQuery(SqlTableLikeSource)

protected virtual void BuildMergeSourceQuery(SqlTableLikeSource mergeSource)

Parameters

mergeSource SqlTableLikeSource

BuildMergeStatement(SqlMergeStatement)

protected virtual void BuildMergeStatement(SqlMergeStatement merge)

Parameters

merge SqlMergeStatement

BuildMergeTerminator(SqlMergeStatement)

Allows to add text after generated merge command. E.g. to specify command terminator if provider requires it.

protected virtual void BuildMergeTerminator(SqlMergeStatement merge)

Parameters

merge SqlMergeStatement

BuildMultiInsertQuery(SqlMultiInsertStatement)

protected virtual void BuildMultiInsertQuery(SqlMultiInsertStatement statement)

Parameters

statement SqlMultiInsertStatement

BuildObjectName(StringBuilder, SqlObjectName, ConvertType, bool, TableOptions, bool)

Writes database object name into provided StringBuilder instance.

public virtual StringBuilder BuildObjectName(StringBuilder sb, SqlObjectName name, ConvertType objectType, bool escape, TableOptions tableOptions, bool withoutSuffix = false)

Parameters

sb StringBuilder

String builder for generated object name.

name SqlObjectName

Name of database object (e.g. table, view, procedure or function).

objectType ConvertType

Type of database object, used to select proper name converter.

escape bool

If true, apply required escaping to name components. Must be true except rare cases when escaping is not needed.

tableOptions TableOptions

Table options if called for table. Used to properly generate names for temporary tables.

withoutSuffix bool

If object name have suffix, which could be detached from main name, this parameter disables suffix generation (enables generation of only main name part).

Returns

StringBuilder

sb parameter value.

BuildObjectNameSuffix(StringBuilder, SqlObjectName, bool)

protected virtual StringBuilder BuildObjectNameSuffix(StringBuilder sb, SqlObjectName name, bool escape)

Parameters

sb StringBuilder
name SqlObjectName
escape bool

Returns

StringBuilder

BuildOffsetLimit(SelectQuery)

protected virtual void BuildOffsetLimit(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildOrderByClause(SelectQuery)

protected virtual void BuildOrderByClause(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildOutputColumnExpressions(IReadOnlyList<ISqlExpression>)

protected virtual void BuildOutputColumnExpressions(IReadOnlyList<ISqlExpression> expressions)

Parameters

expressions IReadOnlyList<ISqlExpression>

BuildOutputSubclause(SqlOutputClause?)

protected virtual void BuildOutputSubclause(SqlOutputClause? output)

Parameters

output SqlOutputClause

BuildOutputSubclause(SqlStatement, SqlInsertClause)

protected virtual void BuildOutputSubclause(SqlStatement statement, SqlInsertClause insertClause)

Parameters

statement SqlStatement
insertClause SqlInsertClause

BuildParameter(SqlParameter)

protected virtual void BuildParameter(SqlParameter parameter)

Parameters

parameter SqlParameter

BuildPhysicalTable(ISqlTableSource, string?, string?)

protected virtual bool? BuildPhysicalTable(ISqlTableSource table, string? alias, string? defaultDatabaseName = null)

Parameters

table ISqlTableSource
alias string
defaultDatabaseName string

Returns

bool?

BuildPredicate(ISqlPredicate)

protected virtual void BuildPredicate(ISqlPredicate predicate)

Parameters

predicate ISqlPredicate

BuildPredicate(int, int, ISqlPredicate)

protected void BuildPredicate(int parentPrecedence, int precedence, ISqlPredicate predicate)

Parameters

parentPrecedence int
precedence int
predicate ISqlPredicate

BuildQueryExtensions(SqlStatement)

protected virtual void BuildQueryExtensions(SqlStatement statement)

Parameters

statement SqlStatement

BuildQueryExtensions(StringBuilder, List<SqlQueryExtension>, string?, string, string?, QueryExtensionScope)

protected void BuildQueryExtensions(StringBuilder sb, List<SqlQueryExtension> sqlQueryExtensions, string? prefix, string delimiter, string? suffix, Sql.QueryExtensionScope scope)

Parameters

sb StringBuilder
sqlQueryExtensions List<SqlQueryExtension>
prefix string
delimiter string
suffix string
scope Sql.QueryExtensionScope

BuildSearchCondition(SqlSearchCondition, bool)

protected virtual void BuildSearchCondition(SqlSearchCondition condition, bool wrapCondition)

Parameters

condition SqlSearchCondition
wrapCondition bool

BuildSearchCondition(int, SqlSearchCondition, bool)

protected virtual void BuildSearchCondition(int parentPrecedence, SqlSearchCondition condition, bool wrapCondition)

Parameters

parentPrecedence int
condition SqlSearchCondition
wrapCondition bool

BuildSelectClause(SelectQuery)

protected virtual void BuildSelectClause(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildSelectQuery(SqlSelectStatement)

protected virtual void BuildSelectQuery(SqlSelectStatement selectStatement)

Parameters

selectStatement SqlSelectStatement

BuildSetOperation(SetOperation, StringBuilder)

protected virtual void BuildSetOperation(SetOperation operation, StringBuilder sb)

Parameters

operation SetOperation
sb StringBuilder

BuildSkipFirst(SelectQuery)

protected virtual void BuildSkipFirst(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildSql()

protected virtual void BuildSql()

BuildSql(int, SqlStatement, StringBuilder, OptimizationContext, int)

public void BuildSql(int commandNumber, SqlStatement statement, StringBuilder sb, OptimizationContext optimizationContext, int startIndent = 0)

Parameters

commandNumber int
statement SqlStatement
sb StringBuilder
optimizationContext OptimizationContext
startIndent int

BuildSql(int, SqlStatement, StringBuilder, OptimizationContext, int, bool)

protected virtual void BuildSql(int commandNumber, SqlStatement statement, StringBuilder sb, OptimizationContext optimizationContext, int indent, bool skipAlias)

Parameters

commandNumber int
statement SqlStatement
sb StringBuilder
optimizationContext OptimizationContext
indent int
skipAlias bool

BuildSqlBuilder(SelectQuery, int, bool)

protected virtual void BuildSqlBuilder(SelectQuery selectQuery, int indent, bool skipAlias)

Parameters

selectQuery SelectQuery
indent int
skipAlias bool

BuildSqlComment(StringBuilder, SqlComment)

protected virtual StringBuilder BuildSqlComment(StringBuilder sb, SqlComment comment)

Parameters

sb StringBuilder
comment SqlComment

Returns

StringBuilder

BuildSqlForUnion()

protected void BuildSqlForUnion()

BuildSqlID(SqlID)

public string BuildSqlID(Sql.SqlID id)

Parameters

id Sql.SqlID

Returns

string

BuildSqlRow(SqlRow, bool, bool, bool)

protected virtual void BuildSqlRow(SqlRow expr, bool buildTableName, bool checkParentheses, bool throwExceptionIfTableNotFound)

Parameters

expr SqlRow
buildTableName bool
checkParentheses bool
throwExceptionIfTableNotFound bool

BuildSqlValuesTable(SqlValuesTable, string, out bool)

protected virtual void BuildSqlValuesTable(SqlValuesTable valuesTable, string alias, out bool aliasBuilt)

Parameters

valuesTable SqlValuesTable
alias string
aliasBuilt bool

BuildStartCreateTableStatement(SqlCreateTableStatement)

protected virtual void BuildStartCreateTableStatement(SqlCreateTableStatement createTable)

Parameters

createTable SqlCreateTableStatement

BuildSubQueryExtensions(SqlStatement)

protected virtual void BuildSubQueryExtensions(SqlStatement statement)

Parameters

statement SqlStatement

BuildTableExtensions(SqlTable, string)

protected virtual void BuildTableExtensions(SqlTable table, string alias)

Parameters

table SqlTable
alias string

BuildTableExtensions(StringBuilder, SqlTable, string, string?, string, string?)

protected void BuildTableExtensions(StringBuilder sb, SqlTable table, string alias, string? prefix, string delimiter, string? suffix)

Parameters

sb StringBuilder
table SqlTable
alias string
prefix string
delimiter string
suffix string

BuildTableExtensions(StringBuilder, SqlTable, string, string?, string, string?, Func<SqlQueryExtension, bool>)

protected void BuildTableExtensions(StringBuilder sb, SqlTable table, string alias, string? prefix, string delimiter, string? suffix, Func<SqlQueryExtension, bool> tableExtensionFilter)

Parameters

sb StringBuilder
table SqlTable
alias string
prefix string
delimiter string
suffix string
tableExtensionFilter Func<SqlQueryExtension, bool>

BuildTableName(SqlTableSource, bool, bool)

protected void BuildTableName(SqlTableSource ts, bool buildName, bool buildAlias)

Parameters

ts SqlTableSource
buildName bool
buildAlias bool

BuildTableNameExtensions(SqlTable)

protected virtual void BuildTableNameExtensions(SqlTable table)

Parameters

table SqlTable

BuildTag(SqlStatement)

protected virtual void BuildTag(SqlStatement statement)

Parameters

statement SqlStatement

BuildTakeHints(SelectQuery)

protected virtual void BuildTakeHints(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildTruncateTable(SqlTruncateTableStatement)

protected virtual void BuildTruncateTable(SqlTruncateTableStatement truncateTable)

Parameters

truncateTable SqlTruncateTableStatement

BuildTruncateTableStatement(SqlTruncateTableStatement)

protected virtual void BuildTruncateTableStatement(SqlTruncateTableStatement truncateTable)

Parameters

truncateTable SqlTruncateTableStatement

BuildTypedExpression(SqlDataType, ISqlExpression)

protected virtual void BuildTypedExpression(SqlDataType dataType, ISqlExpression value)

Parameters

dataType SqlDataType
value ISqlExpression

BuildUnknownQuery()

protected virtual void BuildUnknownQuery()

BuildUpdateClause(SqlStatement, SelectQuery, SqlUpdateClause)

protected virtual void BuildUpdateClause(SqlStatement statement, SelectQuery selectQuery, SqlUpdateClause updateClause)

Parameters

statement SqlStatement
selectQuery SelectQuery
updateClause SqlUpdateClause

BuildUpdateQuery(SqlStatement, SelectQuery, SqlUpdateClause)

protected virtual void BuildUpdateQuery(SqlStatement statement, SelectQuery selectQuery, SqlUpdateClause updateClause)

Parameters

statement SqlStatement
selectQuery SelectQuery
updateClause SqlUpdateClause

BuildUpdateSet(SelectQuery?, SqlUpdateClause)

protected virtual void BuildUpdateSet(SelectQuery? selectQuery, SqlUpdateClause updateClause)

Parameters

selectQuery SelectQuery
updateClause SqlUpdateClause

BuildUpdateTable(SelectQuery, SqlUpdateClause)

protected virtual void BuildUpdateTable(SelectQuery selectQuery, SqlUpdateClause updateClause)

Parameters

selectQuery SelectQuery
updateClause SqlUpdateClause

BuildUpdateTableName(SelectQuery, SqlUpdateClause)

protected virtual void BuildUpdateTableName(SelectQuery selectQuery, SqlUpdateClause updateClause)

Parameters

selectQuery SelectQuery
updateClause SqlUpdateClause

BuildUpdateWhereClause(SelectQuery)

protected virtual void BuildUpdateWhereClause(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildValue(SqlDataType?, object?)

protected void BuildValue(SqlDataType? dataType, object? value)

Parameters

dataType SqlDataType
value object

BuildValues(SqlValuesTable, IReadOnlyList<ISqlExpression[]>)

protected void BuildValues(SqlValuesTable source, IReadOnlyList<ISqlExpression[]> rows)

Parameters

source SqlValuesTable
rows IReadOnlyList<ISqlExpression[]>

BuildWhere(SelectQuery)

protected virtual bool BuildWhere(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

Returns

bool

BuildWhereClause(SelectQuery)

protected virtual void BuildWhereClause(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

BuildWhereSearchCondition(SelectQuery, SqlSearchCondition)

protected virtual void BuildWhereSearchCondition(SelectQuery selectQuery, SqlSearchCondition condition)

Parameters

selectQuery SelectQuery
condition SqlSearchCondition

BuildWithClause(SqlWithClause?)

protected virtual void BuildWithClause(SqlWithClause? with)

Parameters

with SqlWithClause

CanSkipRootAliases(SqlStatement)

protected virtual bool CanSkipRootAliases(SqlStatement statement)

Parameters

statement SqlStatement

Returns

bool

CommandCount(SqlStatement)

public virtual int CommandCount(SqlStatement statement)

Parameters

statement SqlStatement

Returns

int

Convert(StringBuilder, string, ConvertType)

public virtual StringBuilder Convert(StringBuilder sb, string value, ConvertType convertType)

Parameters

sb StringBuilder
value string
convertType ConvertType

Returns

StringBuilder

ConvertElement<T>(T?)

public T? ConvertElement<T>(T? element) where T : class, IQueryElement

Parameters

element T

Returns

T

Type Parameters

T

ConvertInline(string, ConvertType)

public string ConvertInline(string value, ConvertType convertType)

Parameters

value string
convertType ConvertType

Returns

string

CreateSqlBuilder()

protected abstract ISqlBuilder CreateSqlBuilder()

Returns

ISqlBuilder

FinalizeBuildQuery(SqlStatement)

protected virtual void FinalizeBuildQuery(SqlStatement statement)

Parameters

statement SqlStatement

FirstFormat(SelectQuery)

protected virtual string? FirstFormat(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

Returns

string

GetExtensionBuilder(Type)

protected static ISqlExtensionBuilder GetExtensionBuilder(Type builderType)

Parameters

builderType Type

Returns

ISqlExtensionBuilder

GetIdentityExpression(SqlTable)

public virtual ISqlExpression? GetIdentityExpression(SqlTable table)

Parameters

table SqlTable

Returns

ISqlExpression

GetMaxValueSql(EntityDescriptor, ColumnDescriptor)

public virtual string GetMaxValueSql(EntityDescriptor entity, ColumnDescriptor column)

Parameters

entity EntityDescriptor
column ColumnDescriptor

Returns

string

GetPhysicalTableName(ISqlTableSource, string?, bool, string?, bool)

protected virtual string GetPhysicalTableName(ISqlTableSource table, string? alias, bool ignoreTableExpression = false, string? defaultDatabaseName = null, bool withoutSuffix = false)

Parameters

table ISqlTableSource
alias string
ignoreTableExpression bool
defaultDatabaseName string
withoutSuffix bool

Returns

string

GetPrecedence(ISqlPredicate)

protected static int GetPrecedence(ISqlPredicate predicate)

Parameters

predicate ISqlPredicate

Returns

int

GetProviderTypeName(IDataContext, DbParameter)

protected virtual string? GetProviderTypeName(IDataContext dataContext, DbParameter parameter)

Parameters

dataContext IDataContext
parameter DbParameter

Returns

string

GetReserveSequenceValuesSql(int, string)

public virtual string GetReserveSequenceValuesSql(int count, string sequenceName)

Parameters

count int
sequenceName string

Returns

string

GetSelectedColumns(SelectQuery)

protected virtual IEnumerable<SqlColumn> GetSelectedColumns(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

Returns

IEnumerable<SqlColumn>

GetSequenceNameAttribute(SqlTable, bool)

protected SequenceNameAttribute? GetSequenceNameAttribute(SqlTable table, bool throwException)

Parameters

table SqlTable
throwException bool

Returns

SequenceNameAttribute

GetTableAlias(ISqlTableSource)

protected string? GetTableAlias(ISqlTableSource table)

Parameters

table ISqlTableSource

Returns

string

GetTempAliases(int, string)

public string[] GetTempAliases(int n, string defaultAlias)

Parameters

n int
defaultAlias string

Returns

string[]

GetTypeName(IDataContext, DbParameter)

protected virtual string? GetTypeName(IDataContext dataContext, DbParameter parameter)

Parameters

dataContext IDataContext
parameter DbParameter

Returns

string

GetUdtTypeName(IDataContext, DbParameter)

protected virtual string? GetUdtTypeName(IDataContext dataContext, DbParameter parameter)

Parameters

dataContext IDataContext
parameter DbParameter

Returns

string

IsDateDataType(ISqlExpression, string)

protected static bool IsDateDataType(ISqlExpression expr, string dateName)

Parameters

expr ISqlExpression
dateName string

Returns

bool

IsReserved(string)

protected virtual bool IsReserved(string word)

Parameters

word string

Returns

bool

IsSqlValuesTableValueTypeRequired(SqlValuesTable, IReadOnlyList<ISqlExpression[]>, int, int)

Checks that value in specific row and column in enumerable source requires type information generation.

protected virtual bool IsSqlValuesTableValueTypeRequired(SqlValuesTable source, IReadOnlyList<ISqlExpression[]> rows, int row, int column)

Parameters

source SqlValuesTable

Merge source table.

rows IReadOnlyList<ISqlExpression[]>

Merge source data.

row int

Index of data row to check. Could contain -1 to indicate that this is a check for empty source NULL value.

column int

Index of data column to check in row.

Returns

bool

Returns true, if generated SQL should include type information for value at specified position, otherwise false returned.

IsTimeDataType(ISqlExpression)

protected static bool IsTimeDataType(ISqlExpression expr)

Parameters

expr ISqlExpression

Returns

bool

LimitFormat(SelectQuery)

protected virtual string? LimitFormat(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

Returns

string

MergeSqlBuilderData(BasicSqlBuilder)

protected virtual void MergeSqlBuilderData(BasicSqlBuilder sqlBuilder)

Parameters

sqlBuilder BasicSqlBuilder

NeedSkip(ISqlExpression?, ISqlExpression?)

protected bool NeedSkip(ISqlExpression? takeExpression, ISqlExpression? skipExpression)

Parameters

takeExpression ISqlExpression
skipExpression ISqlExpression

Returns

bool

NeedTake(ISqlExpression?)

protected bool NeedTake(ISqlExpression? takeExpression)

Parameters

takeExpression ISqlExpression

Returns

bool

OffsetFormat(SelectQuery)

protected virtual string? OffsetFormat(SelectQuery selectQuery)

Parameters

selectQuery SelectQuery

Returns

string

ParenthesizeJoin(List<SqlJoinedTable>)

protected virtual bool ParenthesizeJoin(List<SqlJoinedTable> joins)

Parameters

joins List<SqlJoinedTable>

Returns

bool

PrintParameterName(StringBuilder, DbParameter)

protected virtual void PrintParameterName(StringBuilder sb, DbParameter parameter)

Parameters

sb StringBuilder
parameter DbParameter

PrintParameterType(IDataContext, StringBuilder, DbParameter)

protected virtual void PrintParameterType(IDataContext dataContext, StringBuilder sb, DbParameter parameter)

Parameters

dataContext IDataContext
sb StringBuilder
parameter DbParameter

PrintParameters(IDataContext, StringBuilder, IEnumerable<DbParameter>?)

public virtual StringBuilder PrintParameters(IDataContext dataContext, StringBuilder sb, IEnumerable<DbParameter>? parameters)

Parameters

dataContext IDataContext
sb StringBuilder
parameters IEnumerable<DbParameter>

Returns

StringBuilder

RemoveAlias(string)

public void RemoveAlias(string alias)

Parameters

alias string

RemoveInlineComma()

protected StringBuilder RemoveInlineComma()

Returns

StringBuilder

StartStatementQueryExtensions(SelectQuery?)

protected virtual void StartStatementQueryExtensions(SelectQuery? selectQuery)

Parameters

selectQuery SelectQuery

TryConvertParameterToSql(SqlParameterValue)

protected virtual bool TryConvertParameterToSql(SqlParameterValue paramValue)

Parameters

paramValue SqlParameterValue

Returns

bool

WithStringBuilderBuildExpression(ISqlExpression)

protected string WithStringBuilderBuildExpression(ISqlExpression expr)

Parameters

expr ISqlExpression

Returns

string

WithStringBuilderBuildExpression(int, ISqlExpression)

protected string WithStringBuilderBuildExpression(int precedence, ISqlExpression expr)

Parameters

precedence int
expr ISqlExpression

Returns

string

WithStringBuilder<TContext>(Action<TContext>, TContext)

protected string WithStringBuilder<TContext>(Action<TContext> func, TContext context)

Parameters

func Action<TContext>
context TContext

Returns

string

Type Parameters

TContext

WrapBooleanExpression(ISqlExpression)

protected virtual ISqlExpression WrapBooleanExpression(ISqlExpression expr)

Parameters

expr ISqlExpression

Returns

ISqlExpression

WrapColumnExpression(ISqlExpression)

protected virtual ISqlExpression WrapColumnExpression(ISqlExpression expr)

Parameters

expr ISqlExpression

Returns

ISqlExpression