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
IDataProvidermappingSchema
MappingSchemadataOptions
DataOptionssqlOptimizer
ISqlOptimizersqlProviderFlags
SqlProviderFlags
BasicSqlBuilder(BasicSqlBuilder)
protected BasicSqlBuilder(BasicSqlBuilder parentBuilder)
Parameters
parentBuilder
BasicSqlBuilder
Fields
BuildExpressionContext
protected object? BuildExpressionContext
Field Value
BuildStep
protected BasicSqlBuilder.Step BuildStep
Field Value
DataProvider
protected IDataProvider? DataProvider
Field Value
EndLine
protected static readonly char[] EndLine
Field Value
- char[]
Indent
protected int Indent
Field Value
SkipAlias
protected bool SkipAlias
Field Value
SqlOptimizer
protected ISqlOptimizer SqlOptimizer
Field Value
Statement
protected SqlStatement Statement
Field Value
Properties
Comma
End-of-line comma separator. Default value:
","
protected virtual string Comma { get; }
Property Value
CteFirst
Identifies CTE clause location:
CteFirst = true
(default): WITH clause goes first in queryCteFirst = false
: WITH clause goes before SELECT
public virtual bool CteFirst { get; }
Property Value
DataOptions
public DataOptions DataOptions { get; }
Property Value
DeletedOutputTable
protected virtual string DeletedOutputTable { get; }
Property Value
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
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
InlineComma
Inline comma separator. Default value:
", "
protected virtual string InlineComma { get; }
Property Value
InsertedOutputTable
protected virtual string InsertedOutputTable { get; }
Property Value
IsCteColumnListSupported
protected virtual bool IsCteColumnListSupported { get; }
Property Value
IsEmptyValuesSourceSupported
If true, builder will generate command for empty enumerable source; Otherwise exception will be generated.
protected virtual bool IsEmptyValuesSourceSupported { get; }
Property Value
IsNestedJoinParenthesisRequired
public virtual bool IsNestedJoinParenthesisRequired { get; }
Property Value
IsNestedJoinSupported
public virtual bool IsNestedJoinSupported { get; }
Property Value
IsRecursiveCteKeywordRequired
protected virtual bool IsRecursiveCteKeywordRequired { get; }
Property Value
IsValuesSyntaxSupported
If true, provider supports list of VALUES as a source element of merge command.
protected virtual bool IsValuesSyntaxSupported { get; }
Property Value
MappingSchema
public MappingSchema MappingSchema { get; }
Property Value
Name
public virtual string Name { get; }
Property Value
OffsetFirst
protected virtual bool OffsetFirst { get; }
Property Value
OpenParens
End-of-line open parentheses element. Default value:
"("
protected virtual string OpenParens { get; }
Property Value
OptimizationContext
public OptimizationContext OptimizationContext { get; protected set; }
Property Value
OutputKeyword
protected virtual string OutputKeyword { get; }
Property Value
QueryName
public string? QueryName { get; set; }
Property Value
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
SkipFirst
protected virtual bool SkipFirst { get; }
Property Value
SkipFormat
protected virtual string? SkipFormat { get; }
Property Value
SqlProviderFlags
public SqlProviderFlags SqlProviderFlags { get; }
Property Value
StringBuilder
public StringBuilder StringBuilder { get; set; }
Property Value
SupportsBooleanInColumn
protected virtual bool SupportsBooleanInColumn { get; }
Property Value
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
SupportsNullInColumn
protected virtual bool SupportsNullInColumn { get; }
Property Value
TableIDs
public Dictionary<string, TableIDInfo>? TableIDs { get; set; }
Property Value
TablePath
public string? TablePath { get; set; }
Property Value
TakePercent
protected virtual string TakePercent { get; }
Property Value
TakeTies
protected virtual string TakeTies { get; }
Property Value
UpdateKeyword
protected virtual string UpdateKeyword { get; }
Property Value
UpdateSetKeyword
protected virtual string UpdateSetKeyword { get; }
Property Value
ValueToSqlConverter
protected ValueToSqlConverter ValueToSqlConverter { get; }
Property Value
WrapJoinCondition
True if it is needed to wrap join condition with ()
public virtual bool WrapJoinCondition { get; }
Property Value
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
SelectQuerycolumns
IEnumerable<SqlColumn>
Returns
AppendIndent()
protected StringBuilder AppendIndent()
Returns
ApplyQueryHints(string, IReadOnlyCollection<string>)
public string ApplyQueryHints(string sqlText, IReadOnlyCollection<string> queryHints)
Parameters
sqlText
stringqueryHints
IReadOnlyCollection<string>
Returns
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
SelectQueryexpr
ISqlExpressionalias
stringaddAlias
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
SqlStatementcommandNumber
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
SqlFielddefaultNullable
DefaultNullable
BuildCreateTablePrimaryKey(SqlCreateTableStatement, string, IEnumerable<string>)
protected virtual void BuildCreateTablePrimaryKey(SqlCreateTableStatement createTable, string pkName, IEnumerable<string> fieldNames)
Parameters
createTable
SqlCreateTableStatementpkName
stringfieldNames
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
SqlDataTypeforCreateTable
boolcanBeNull
boolType 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
StringBuilderdataType
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
SqlDataTypeforCreateTable
boolcanBeNull
boolType 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
BuildExpression(ISqlExpression, bool, bool, bool)
public void BuildExpression(ISqlExpression expr, bool buildTableName, bool checkParentheses, bool throwExceptionIfTableNotFound = true)
Parameters
expr
ISqlExpressionbuildTableName
boolcheckParentheses
boolthrowExceptionIfTableNotFound
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
ISqlExpressionbuildTableName
boolcheckParentheses
boolalias
stringaddAlias
boolthrowExceptionIfTableNotFound
bool
Returns
BuildExpression(int, ISqlExpression)
protected void BuildExpression(int precedence, ISqlExpression expr)
Parameters
precedence
intexpr
ISqlExpression
BuildExpressionForOrderBy(ISqlExpression)
protected virtual void BuildExpressionForOrderBy(ISqlExpression expr)
Parameters
expr
ISqlExpression
BuildFakeTableName()
protected virtual bool BuildFakeTableName()
Returns
BuildFieldTableAlias(SqlField)
Used to disable field table name (alias) generation.
protected virtual bool BuildFieldTableAlias(SqlField field)
Parameters
field
SqlField
Returns
BuildFromClause(SqlStatement, SelectQuery)
protected virtual void BuildFromClause(SqlStatement statement, SelectQuery selectQuery)
Parameters
statement
SqlStatementselectQuery
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
GroupingTypeitems
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
SqlStatementinsertClause
SqlInsertClauseaddAlias
bool
BuildInsertClause(SqlStatement, SqlInsertClause, string?, bool, bool)
protected virtual void BuildInsertClause(SqlStatement statement, SqlInsertClause insertClause, string? insertText, bool appendTableName, bool addAlias)
Parameters
statement
SqlStatementinsertClause
SqlInsertClauseinsertText
stringappendTableName
booladdAlias
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
SqlInsertOrUpdateStatementfromDummyTable
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
SqlStatementinsertClause
SqlInsertClauseaddAlias
bool
BuildInsertQuery2(SqlStatement, SqlInsertClause, bool)
protected void BuildInsertQuery2(SqlStatement statement, SqlInsertClause insertClause, bool addAlias)
Parameters
statement
SqlStatementinsertClause
SqlInsertClauseaddAlias
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
SelectQueryjoin
SqlJoinedTablejoinCounter
int
BuildJoinType(SqlJoinedTable, SqlSearchCondition)
protected virtual bool BuildJoinType(SqlJoinedTable join, SqlSearchCondition condition)
Parameters
join
SqlJoinedTablecondition
SqlSearchCondition
Returns
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
StringBuilderString builder for generated object name.
name
SqlObjectNameName of database object (e.g. table, view, procedure or function).
objectType
ConvertTypeType of database object, used to select proper name converter.
escape
boolIf
true
, apply required escaping to name components. Must betrue
except rare cases when escaping is not needed.tableOptions
TableOptionsTable options if called for table. Used to properly generate names for temporary tables.
withoutSuffix
boolIf 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
StringBuildername
SqlObjectNameescape
bool
Returns
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
SqlStatementinsertClause
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
ISqlTableSourcealias
stringdefaultDatabaseName
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
intprecedence
intpredicate
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
StringBuildersqlQueryExtensions
List<SqlQueryExtension>prefix
stringdelimiter
stringsuffix
stringscope
Sql.QueryExtensionScope
BuildSearchCondition(SqlSearchCondition, bool)
protected virtual void BuildSearchCondition(SqlSearchCondition condition, bool wrapCondition)
Parameters
condition
SqlSearchConditionwrapCondition
bool
BuildSearchCondition(int, SqlSearchCondition, bool)
protected virtual void BuildSearchCondition(int parentPrecedence, SqlSearchCondition condition, bool wrapCondition)
Parameters
parentPrecedence
intcondition
SqlSearchConditionwrapCondition
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
SetOperationsb
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
intstatement
SqlStatementsb
StringBuilderoptimizationContext
OptimizationContextstartIndent
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
intstatement
SqlStatementsb
StringBuilderoptimizationContext
OptimizationContextindent
intskipAlias
bool
BuildSqlBuilder(SelectQuery, int, bool)
protected virtual void BuildSqlBuilder(SelectQuery selectQuery, int indent, bool skipAlias)
Parameters
selectQuery
SelectQueryindent
intskipAlias
bool
BuildSqlComment(StringBuilder, SqlComment)
protected virtual StringBuilder BuildSqlComment(StringBuilder sb, SqlComment comment)
Parameters
sb
StringBuildercomment
SqlComment
Returns
BuildSqlForUnion()
protected void BuildSqlForUnion()
BuildSqlID(SqlID)
public string BuildSqlID(Sql.SqlID id)
Parameters
Returns
BuildSqlRow(SqlRow, bool, bool, bool)
protected virtual void BuildSqlRow(SqlRow expr, bool buildTableName, bool checkParentheses, bool throwExceptionIfTableNotFound)
Parameters
BuildSqlValuesTable(SqlValuesTable, string, out bool)
protected virtual void BuildSqlValuesTable(SqlValuesTable valuesTable, string alias, out bool aliasBuilt)
Parameters
valuesTable
SqlValuesTablealias
stringaliasBuilt
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
BuildTableExtensions(StringBuilder, SqlTable, string, string?, string, string?)
protected void BuildTableExtensions(StringBuilder sb, SqlTable table, string alias, string? prefix, string delimiter, string? suffix)
Parameters
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
StringBuildertable
SqlTablealias
stringprefix
stringdelimiter
stringsuffix
stringtableExtensionFilter
Func<SqlQueryExtension, bool>
BuildTableName(SqlTableSource, bool, bool)
protected void BuildTableName(SqlTableSource ts, bool buildName, bool buildAlias)
Parameters
ts
SqlTableSourcebuildName
boolbuildAlias
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
SqlDataTypevalue
ISqlExpression
BuildUnknownQuery()
protected virtual void BuildUnknownQuery()
BuildUpdateClause(SqlStatement, SelectQuery, SqlUpdateClause)
protected virtual void BuildUpdateClause(SqlStatement statement, SelectQuery selectQuery, SqlUpdateClause updateClause)
Parameters
statement
SqlStatementselectQuery
SelectQueryupdateClause
SqlUpdateClause
BuildUpdateQuery(SqlStatement, SelectQuery, SqlUpdateClause)
protected virtual void BuildUpdateQuery(SqlStatement statement, SelectQuery selectQuery, SqlUpdateClause updateClause)
Parameters
statement
SqlStatementselectQuery
SelectQueryupdateClause
SqlUpdateClause
BuildUpdateSet(SelectQuery?, SqlUpdateClause)
protected virtual void BuildUpdateSet(SelectQuery? selectQuery, SqlUpdateClause updateClause)
Parameters
selectQuery
SelectQueryupdateClause
SqlUpdateClause
BuildUpdateTable(SelectQuery, SqlUpdateClause)
protected virtual void BuildUpdateTable(SelectQuery selectQuery, SqlUpdateClause updateClause)
Parameters
selectQuery
SelectQueryupdateClause
SqlUpdateClause
BuildUpdateTableName(SelectQuery, SqlUpdateClause)
protected virtual void BuildUpdateTableName(SelectQuery selectQuery, SqlUpdateClause updateClause)
Parameters
selectQuery
SelectQueryupdateClause
SqlUpdateClause
BuildUpdateWhereClause(SelectQuery)
protected virtual void BuildUpdateWhereClause(SelectQuery selectQuery)
Parameters
selectQuery
SelectQuery
BuildValue(SqlDataType?, object?)
protected void BuildValue(SqlDataType? dataType, object? value)
Parameters
dataType
SqlDataTypevalue
object
BuildValues(SqlValuesTable, IReadOnlyList<ISqlExpression[]>)
protected void BuildValues(SqlValuesTable source, IReadOnlyList<ISqlExpression[]> rows)
Parameters
source
SqlValuesTablerows
IReadOnlyList<ISqlExpression[]>
BuildWhere(SelectQuery)
protected virtual bool BuildWhere(SelectQuery selectQuery)
Parameters
selectQuery
SelectQuery
Returns
BuildWhereClause(SelectQuery)
protected virtual void BuildWhereClause(SelectQuery selectQuery)
Parameters
selectQuery
SelectQuery
BuildWhereSearchCondition(SelectQuery, SqlSearchCondition)
protected virtual void BuildWhereSearchCondition(SelectQuery selectQuery, SqlSearchCondition condition)
Parameters
selectQuery
SelectQuerycondition
SqlSearchCondition
BuildWithClause(SqlWithClause?)
protected virtual void BuildWithClause(SqlWithClause? with)
Parameters
with
SqlWithClause
CanSkipRootAliases(SqlStatement)
protected virtual bool CanSkipRootAliases(SqlStatement statement)
Parameters
statement
SqlStatement
Returns
CommandCount(SqlStatement)
public virtual int CommandCount(SqlStatement statement)
Parameters
statement
SqlStatement
Returns
Convert(StringBuilder, string, ConvertType)
public virtual StringBuilder Convert(StringBuilder sb, string value, ConvertType convertType)
Parameters
sb
StringBuildervalue
stringconvertType
ConvertType
Returns
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
stringconvertType
ConvertType
Returns
CreateSqlBuilder()
protected abstract ISqlBuilder CreateSqlBuilder()
Returns
FinalizeBuildQuery(SqlStatement)
protected virtual void FinalizeBuildQuery(SqlStatement statement)
Parameters
statement
SqlStatement
FirstFormat(SelectQuery)
protected virtual string? FirstFormat(SelectQuery selectQuery)
Parameters
selectQuery
SelectQuery
Returns
GetExtensionBuilder(Type)
protected static ISqlExtensionBuilder GetExtensionBuilder(Type builderType)
Parameters
builderType
Type
Returns
GetIdentityExpression(SqlTable)
public virtual ISqlExpression? GetIdentityExpression(SqlTable table)
Parameters
table
SqlTable
Returns
GetMaxValueSql(EntityDescriptor, ColumnDescriptor)
public virtual string GetMaxValueSql(EntityDescriptor entity, ColumnDescriptor column)
Parameters
entity
EntityDescriptorcolumn
ColumnDescriptor
Returns
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
ISqlTableSourcealias
stringignoreTableExpression
booldefaultDatabaseName
stringwithoutSuffix
bool
Returns
GetPrecedence(ISqlPredicate)
protected static int GetPrecedence(ISqlPredicate predicate)
Parameters
predicate
ISqlPredicate
Returns
GetProviderTypeName(IDataContext, DbParameter)
protected virtual string? GetProviderTypeName(IDataContext dataContext, DbParameter parameter)
Parameters
dataContext
IDataContextparameter
DbParameter
Returns
GetReserveSequenceValuesSql(int, string)
public virtual string GetReserveSequenceValuesSql(int count, string sequenceName)
Parameters
Returns
GetSelectedColumns(SelectQuery)
protected virtual IEnumerable<SqlColumn> GetSelectedColumns(SelectQuery selectQuery)
Parameters
selectQuery
SelectQuery
Returns
GetSequenceNameAttribute(SqlTable, bool)
protected SequenceNameAttribute? GetSequenceNameAttribute(SqlTable table, bool throwException)
Parameters
Returns
GetTableAlias(ISqlTableSource)
protected string? GetTableAlias(ISqlTableSource table)
Parameters
table
ISqlTableSource
Returns
GetTempAliases(int, string)
public string[] GetTempAliases(int n, string defaultAlias)
Parameters
Returns
- string[]
GetTypeName(IDataContext, DbParameter)
protected virtual string? GetTypeName(IDataContext dataContext, DbParameter parameter)
Parameters
dataContext
IDataContextparameter
DbParameter
Returns
GetUdtTypeName(IDataContext, DbParameter)
protected virtual string? GetUdtTypeName(IDataContext dataContext, DbParameter parameter)
Parameters
dataContext
IDataContextparameter
DbParameter
Returns
IsDateDataType(ISqlExpression, string)
protected static bool IsDateDataType(ISqlExpression expr, string dateName)
Parameters
expr
ISqlExpressiondateName
string
Returns
IsReserved(string)
protected virtual bool IsReserved(string word)
Parameters
word
string
Returns
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
SqlValuesTableMerge source table.
rows
IReadOnlyList<ISqlExpression[]>Merge source data.
row
intIndex of data row to check. Could contain -1 to indicate that this is a check for empty source NULL value.
column
intIndex of data column to check in row.
Returns
- bool
Returns
true
, if generated SQL should include type information for value at specified position, otherwisefalse
returned.
IsTimeDataType(ISqlExpression)
protected static bool IsTimeDataType(ISqlExpression expr)
Parameters
expr
ISqlExpression
Returns
LimitFormat(SelectQuery)
protected virtual string? LimitFormat(SelectQuery selectQuery)
Parameters
selectQuery
SelectQuery
Returns
MergeSqlBuilderData(BasicSqlBuilder)
protected virtual void MergeSqlBuilderData(BasicSqlBuilder sqlBuilder)
Parameters
sqlBuilder
BasicSqlBuilder
NeedSkip(ISqlExpression?, ISqlExpression?)
protected bool NeedSkip(ISqlExpression? takeExpression, ISqlExpression? skipExpression)
Parameters
takeExpression
ISqlExpressionskipExpression
ISqlExpression
Returns
NeedTake(ISqlExpression?)
protected bool NeedTake(ISqlExpression? takeExpression)
Parameters
takeExpression
ISqlExpression
Returns
OffsetFormat(SelectQuery)
protected virtual string? OffsetFormat(SelectQuery selectQuery)
Parameters
selectQuery
SelectQuery
Returns
ParenthesizeJoin(List<SqlJoinedTable>)
protected virtual bool ParenthesizeJoin(List<SqlJoinedTable> joins)
Parameters
joins
List<SqlJoinedTable>
Returns
PrintParameterName(StringBuilder, DbParameter)
protected virtual void PrintParameterName(StringBuilder sb, DbParameter parameter)
Parameters
sb
StringBuilderparameter
DbParameter
PrintParameterType(IDataContext, StringBuilder, DbParameter)
protected virtual void PrintParameterType(IDataContext dataContext, StringBuilder sb, DbParameter parameter)
Parameters
dataContext
IDataContextsb
StringBuilderparameter
DbParameter
PrintParameters(IDataContext, StringBuilder, IEnumerable<DbParameter>?)
public virtual StringBuilder PrintParameters(IDataContext dataContext, StringBuilder sb, IEnumerable<DbParameter>? parameters)
Parameters
dataContext
IDataContextsb
StringBuilderparameters
IEnumerable<DbParameter>
Returns
RemoveAlias(string)
public void RemoveAlias(string alias)
Parameters
alias
string
RemoveInlineComma()
protected StringBuilder RemoveInlineComma()
Returns
StartStatementQueryExtensions(SelectQuery?)
protected virtual void StartStatementQueryExtensions(SelectQuery? selectQuery)
Parameters
selectQuery
SelectQuery
TryConvertParameterToSql(SqlParameterValue)
protected virtual bool TryConvertParameterToSql(SqlParameterValue paramValue)
Parameters
paramValue
SqlParameterValue
Returns
WithStringBuilderBuildExpression(ISqlExpression)
protected string WithStringBuilderBuildExpression(ISqlExpression expr)
Parameters
expr
ISqlExpression
Returns
WithStringBuilderBuildExpression(int, ISqlExpression)
protected string WithStringBuilderBuildExpression(int precedence, ISqlExpression expr)
Parameters
precedence
intexpr
ISqlExpression
Returns
WithStringBuilder<TContext>(Action<TContext>, TContext)
protected string WithStringBuilder<TContext>(Action<TContext> func, TContext context)
Parameters
func
Action<TContext>context
TContext
Returns
Type Parameters
TContext
WrapBooleanExpression(ISqlExpression)
protected virtual ISqlExpression WrapBooleanExpression(ISqlExpression expr)
Parameters
expr
ISqlExpression
Returns
WrapColumnExpression(ISqlExpression)
protected virtual ISqlExpression WrapColumnExpression(ISqlExpression expr)
Parameters
expr
ISqlExpression