Skip to main content

dbquerybuilder-class

Lets you build SQL commands based on Korzh.EasyQuery.Db.DbQuery object

public abstract class Korzh.EasyQuery.Db.DbQueryBuilder
: IQueryBuilder

Assembly: Korzh.EasyQuery.Db.dll

Constructors

NameTypeDescription
DbQueryBuilder(DbQuery query)voidInitializes a new instance of the Korzh.EasyQuery.Db.DbQueryBuilder class.

Fields

NameTypeDescription
_isParamModeboolThis property indicated whethere generated SQL should include parameters instead of real values.
condFieldNamestringThe name of the field in currently processing condition (used for generation of parameter names)

Properties

NameTypeDescription
EscapeDefstringcontains escape symbol definition which will be added to the condition if necessary
ExtrasSqlExtrasGets the Korzh.EasyQuery.Db.SqlExtras object which defines some extra clauses and options of the generated query.
FormatsSqlFormatsGets the formats of the result query statement. This is a structure which allows you to set different formatting option of generated SQL (or other query language) statements. For more information please read Korzh.EasyQuery.Db.SqlFormats reference.
ModelDbModelGets the model. An instance of Korzh.EasyQuery.DataModel class or one of its descendants (for example DbModel)
OptionsQueryBuilderOptionsGets or sets the builder's options.
QueryDbQueryGets the query object associated with the builder.
QueryParamsQueryParamListGets the list of query parameters (for parameterized queries)
ResultQueryStatementQueryBuilder result.
StatementTypeTypeGets the the statement type.

Events

NameTypeDescription
ConditionSqlGeneratedConditionSqlGeneratedEventHandlerThis event is raised during query building for each condition in the query and it allows you to replace the SQL expression generated for this condition.

Methods

NameTypeDescription
AddExtraParams(QueryParamList extraParams)voidAdds the list of extra parameters (mainly for sub-queries)
Build()boolBuilds the query and stores the result in the Korzh.EasyQuery.Db.DbQueryBuilder.Result property. The result could be some SQL statement or and an IQueryable object created by LINQ query builder.
CalcScalarExpr(Condition cnd, string value, DataType dataType, ScalarExprOptions exprOptions)stringCalculates the scalar value and returns SQL (or other query language) expression. This function replaces all macros with their real values first and then call Korzh.EasyQuery.Db.DbQueryBuilder.ProcessScalarValue(Korzh.EasyQuery.Condition,System.String,EasyData.DataType,Korzh.EasyQuery.ScalarExprOptions) method to get the result.
GetGroupByExpr(QueryColumn column, SqlFormats formats)stringGets the column's expression using in GROUP BY clause.
GetOrderByExpr(QueryColumn column, SqlFormats formats)stringGets the columns expression for ORDER BY clause.
GetParamExpr(string id)stringGets the parameter expression.
GetSelectExpr(QueryColumn column, SqlFormats formats)stringGets the columns expression for SELECT clause.
ProcessDefaultMacros(StringBuilder sb, bool quoting = False)voidProcesses the default macros such as ${{Today}}, ${{True}} and others.
ProcessFunctions(StringBuilder sb)voidProcesses the functions
ProcessMacros(Condition cnd, StringBuilder sb, DataType dataType, ScalarExprOptions exprOptions)voidProcesses the macro values (both user-defined and default)
ProcessScalarValue(Condition cnd, string value, DataType dataType, ScalarExprOptions exprOptions)stringProcesses the scalar value and returns SQL (or other query language) expression.
ResetGeneratedParams()voidReset the list of parameters if its necessary