Class ProSqlBuilder
SQLite-specific SQL builder for Pro version.
Inherits field mapping and filter extraction from ProSqlBuilderBase.
Contains SQLite-specific SQL generation (PVT, WHERE, SELECT, ORDER BY).
public class ProSqlBuilder : ProSqlBuilderBase
Inheritance
Inherited Members
Methods
ApplyFunction(PropertyFunction, string)
Pro: Apply SQL function to column
public string ApplyFunction(PropertyFunction function, string column)
ApplyPropertyFunction(string, PropertyFunction?)
public string ApplyPropertyFunction(string column, PropertyFunction? function)
BaseGroupColumns(IEnumerable<GroupFieldRequest>)
Columns of _objects the base GROUP BY keys read, for the pivot to expose.
public static List<string> BaseGroupColumns(IEnumerable<GroupFieldRequest> groups)
BuildAggregateSelectColumn(AggregateFunction, string, string, IReadOnlyDictionary<string, FieldInfo>, SqlParameterCollector, int?)
Generates full aggregation column (for SELECT)
public string BuildAggregateSelectColumn(AggregateFunction func, string fieldPath, string alias, IReadOnlyDictionary<string, FieldInfo> fields, SqlParameterCollector collector, int? arrayIndex = null)
BuildFieldReference(string, IReadOnlyDictionary<string, FieldInfo>, SqlParameterCollector?, string)
Generates column for GROUP BY or ORDER BY (base or Props)
public string BuildFieldReference(string fieldPath, IReadOnlyDictionary<string, FieldInfo> fields, SqlParameterCollector? collector, string tableAlias = "pvt")
BuildGroupKeyColumn(GroupFieldRequest, IReadOnlyDictionary<string, FieldInfo>, string)
The pivot column a GROUP BY key reads: the object's own column for a base key, the pivot
public string BuildGroupKeyColumn(GroupFieldRequest group, IReadOnlyDictionary<string, FieldInfo> fields, string tableAlias = "pvt")
BuildLimitOffset<TProps>(QueryContext<TProps>, SqlParameterCollector?)
Generates LIMIT/OFFSET clause
public string BuildLimitOffset<TProps>(QueryContext<TProps> context, SqlParameterCollector? collector = null) where TProps : class, new()
BuildNestedFieldAliases(IReadOnlyList<FieldInfo>)
Builds mapping from nested Dictionary field names to their CTE aliases.
public static Dictionary<string, string> BuildNestedFieldAliases(IReadOnlyList<FieldInfo> fields)
BuildOrderByClause<TProps>(QueryContext<TProps>, IReadOnlyDictionary<string, FieldInfo>, string?, SqlParameterCollector?, IReadOnlySet<string>?, string, string)
Generates ORDER BY clause with DISTINCT ON support.
public string BuildOrderByClause<TProps>(QueryContext<TProps> context, IReadOnlyDictionary<string, FieldInfo> fields, string? distinctOnExpr, SqlParameterCollector? collector = null, IReadOnlySet<string>? cteFieldNames = null, string cteAlias = "pvt_cte", string baseAlias = "o") where TProps : class, new()
BuildPropsValueSubquery(FieldInfo, string, int?)
Generates subquery for getting Props value
public string BuildPropsValueSubquery(FieldInfo field, string structureIdSql, int? arrayIndex = null)
BuildPvtColumn(FieldInfo, string)
Generates PVT column for GROUP BY
public string BuildPvtColumn(FieldInfo field, string structureIdSql)
BuildPvtSubquery(long, IReadOnlyCollection<FieldInfo>, IReadOnlyCollection<string>, SqlParameterCollector, string?)
Generates PVT subquery for GROUP BY
public string BuildPvtSubquery(long schemeId, IReadOnlyCollection<FieldInfo> pvtFields, IReadOnlyCollection<string> baseFieldColumns, SqlParameterCollector collector, string? additionalWhereClause = null)
BuildSelectClause<TProps>(QueryContext<TProps>, IReadOnlyDictionary<string, FieldInfo>, SqlParameterCollector, IReadOnlySet<string>?, string)
Generates SELECT clause with DISTINCT ON support.
public (string SelectClause, string? DistinctOnExpr) BuildSelectClause<TProps>(QueryContext<TProps> context, IReadOnlyDictionary<string, FieldInfo> fields, SqlParameterCollector collector, IReadOnlySet<string>? cteFieldNames = null, string cteAlias = "pvt_cte") where TProps : class, new()
CompileBaseFieldsForObjectsSubquery(FilterExpression, SqlParameterCollector?, string)
Compiles ONLY base fields with a custom table alias prefix (or none).
public string? CompileBaseFieldsForObjectsSubquery(FilterExpression filter, SqlParameterCollector? collector, string baseTableAlias = "")
CompileBaseFieldsOnly(FilterExpression, SqlParameterCollector?)
Compiles ONLY base fields (Name, Id, DateCreate, etc.) for direct WHERE
public string? CompileBaseFieldsOnly(FilterExpression filter, SqlParameterCollector? collector)
CompileFilterToSql(FilterExpression, IReadOnlyDictionary<string, FieldInfo>, SqlParameterCollector?)
Compiles FilterExpression to SQL WHERE
public string CompileFilterToSql(FilterExpression filter, IReadOnlyDictionary<string, FieldInfo> fields, SqlParameterCollector? collector = null)
CompilePropsFieldsOnly(FilterExpression, IReadOnlyDictionary<string, FieldInfo>, SqlParameterCollector?, IReadOnlyDictionary<string, string>?, bool)
Compiles ONLY Props fields for PVT EXISTS.
public string? CompilePropsFieldsOnly(FilterExpression filter, IReadOnlyDictionary<string, FieldInfo> fields, SqlParameterCollector? collector, IReadOnlyDictionary<string, string>? nestedFieldAliases = null, bool arrayLeavesAsExists = false)
ExtractBaseFieldName(string?)
Extracts real field name from format "0$:FieldName"
public static string ExtractBaseFieldName(string? fieldPath)
ExtractPropsFieldPaths(IEnumerable<AggregateRequest>)
Collects Props fields from aggregation list (excluding base and COUNT(*))
public HashSet<string> ExtractPropsFieldPaths(IEnumerable<AggregateRequest> aggregations)
FormatValueLegacy(object?)
public string FormatValueLegacy(object? value)
HiddenWindowAggregates(IEnumerable<string>, IReadOnlyList<AggregateRequest>)
Aggregates a grouped window sorts or partitions by without the selector computing them:
public static List<AggregateRequest> HiddenWindowAggregates(IEnumerable<string> windowFieldPaths, IReadOnlyList<AggregateRequest> aggregations)
IsBaseAggregate(AggregateRequest)
Whether an aggregate reads a field of the object itself: its request says so (x.Id in
public static bool IsBaseAggregate(AggregateRequest aggregate)
IsBaseFieldPath(string?)
Checks if field is base field (considering "0$:" prefix)
public bool IsBaseFieldPath(string? fieldPath)
IsBaseGroupField(GroupFieldRequest)
Whether a GROUP BY key is a base field: its request says so (GroupByRedb), or its path carries
public static bool IsBaseGroupField(GroupFieldRequest group)
IsMarkedBaseField(string?)
Whether a field path carries the 0$: mark of a base field.
public static bool IsMarkedBaseField(string? fieldPath)
MapAggregateFunction(AggregateFunction)
Mapping AggregateFunction → SQL function
public static string MapAggregateFunction(AggregateFunction func)
MarkBaseField(string)
The path with the 0$: mark put on it, for code that passes paths without their request.
public static string MarkBaseField(string fieldPath)
ResolveGroupedWindowColumn(string, IReadOnlyList<AggregateRequest>, IReadOnlyList<GroupFieldRequest>)
The column of the grouped subquery that a window ORDER BY or PARTITION BY of a grouped query
public static string ResolveGroupedWindowColumn(string fieldPath, IReadOnlyList<AggregateRequest> aggregations, IReadOnlyList<GroupFieldRequest> groupFields)