DbQueryBuilder class

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

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

Package: Korzh.EasyQuery.Db (targets: netstandard2.0)

Assembly: Korzh.EasyQuery.Db.dll

Constructors

Name Type Description
DbQueryBuilder(DbQuery query) void Initializes a new instance of the Korzh.EasyQuery.Db.DbQueryBuilder class.

Fields

Name Type Description
_isParamMode bool This property indicated whethere generated SQL should include parameters instead of real values.
condFieldName string The name of the field in currently processing condition (used for generation of parameter names)

Properties

Name Type Description
EscapeDef string contains escape symbol definition which will be added to the condition if necessary
Extras SqlExtras Gets the Korzh.EasyQuery.Db.SqlExtras object which defines some extra clauses and options of the generated query.
Formats SqlFormats Gets 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.
Model DbModel Gets the model. An instance of Korzh.EasyQuery.DataModel class or one of its descendants (for example DbModel)
Options QueryBuilderOptions Gets or sets the builder's options.
Query DbQuery Gets the query object associated with the builder.
QueryParams QueryParamList Gets the list of query parameters (for parameterized queries)
Result QueryStatement QueryBuilder result.
StatementType Type Gets the the statement type.

Events

Name Type Description
ConditionSqlGenerated ConditionSqlGeneratedEventHandler This 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

Name Type Description
Build() bool Builds 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) string Calculates 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) string Gets the column's expression using in GROUP BY clause.
GetOrderByExpr(QueryColumn column, SqlFormats formats) string Gets the columns expression for ORDER BY clause.
GetParamExpr(string id) string Gets the parameter expression.
GetSelectExpr(QueryColumn column, SqlFormats formats) string Gets the columns expression for SELECT clause.
ProcessDefaultMacros(StringBuilder sb, bool quoting = False) void Processes the default macros such as ${{Today}}, ${{True}} and others.
ProcessMacros(Condition cnd, StringBuilder sb, DataType dataType, ScalarExprOptions exprOptions) void Processes the macro values (both user-defined and default)
ProcessScalarValue(Condition cnd, string value, DataType dataType, ScalarExprOptions exprOptions) string Processes the scalar value and returns SQL (or other query language) expression.
ResetParamsIfNeeded() void Reset the list of parameters if its necessary
SetExtraParams(QueryParamList extraParams) void Sets the list of extra parameters (mainly for sub-queries)