Class ProSqlBuilder

Assembly: redb.Postgres.Pro.dll

PostgreSQL-specific SQL builder for Pro version.
Inherits field mapping and filter extraction from ProSqlBuilderBase.
Contains PostgreSQL-specific SQL generation (PVT, WHERE, SELECT, ORDER BY).

public class ProSqlBuilder : ProSqlBuilderBase

Inheritance

ObjectProSqlBuilderBaseProSqlBuilder

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)

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")

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)

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") where TProps : class, new()

BuildPropsValueSubquery(FieldInfo, string, int?)

Generates subquery for getting Props value

public string BuildPropsValueSubquery(FieldInfo field, string structureIdParam, int? arrayIndex = null)

BuildPvtColumn(FieldInfo, string)

Generates PVT column for GROUP BY

public string BuildPvtColumn(FieldInfo field, string structureIdParam)

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()

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>?)

Compiles ONLY Props fields for PVT EXISTS.

public string? CompilePropsFieldsOnly(FilterExpression filter, IReadOnlyDictionary<string, FieldInfo> fields, SqlParameterCollector? collector, IReadOnlyDictionary<string, string>? nestedFieldAliases = null)

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)

IsBaseFieldPath(string?)

Checks if field is base field (considering "0$:" prefix)

public bool IsBaseFieldPath(string? fieldPath)

MapAggregateFunction(AggregateFunction)

Mapping AggregateFunction → SQL function

public static string MapAggregateFunction(AggregateFunction func)

Constructors