Class ProTreeQueryProvider

Assembly: redb.Postgres.Pro.dll

ProTreeQueryProvider - Aggregation for trees (partial).
CTE for tree traversal + aggregations.
✅ DRY: Uses ProSqlBuilder for common operations.

public class ProTreeQueryProvider : PostgresTreeQueryProvider, ITreeQueryProvider, IRedbQueryProvider

Inheritance

Implements

Inherited Members

TreeQueryProviderBase.Cache,TreeQueryProviderBase.CheckProOnlyDistinctFeatures<TProps>(QueryContext<TProps>),TreeQueryProviderBase.CreateFacetBuilder(),TreeQueryProviderBase.CreateFilterParser(),TreeQueryProviderBase.CreateOrderingParser(),TreeQueryProviderBase.CreateQuery<TProps>(long, long?, bool),TreeQueryProviderBase.CreateQueryProvider(),TreeQueryProviderBase.CreateTreeQuery<TProps>(long, long?, bool, long?, int?),TreeQueryProviderBase.CreateTreeQueryable<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.ExecuteAggregateAsync(long, string, AggregateFunction, FilterExpression?),TreeQueryProviderBase.ExecuteAggregateAsync(long, string, AggregateFunction, string?),TreeQueryProviderBase.ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, FilterExpression?),TreeQueryProviderBase.ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, string?),TreeQueryProviderBase.ExecuteArrayGroupedAggregateAsync(long, string, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?),TreeQueryProviderBase.ExecuteAsync(Expression, Type),TreeQueryProviderBase.ExecuteDeleteAsync(long, FilterExpression?),TreeQueryProviderBase.ExecuteDeleteAsync(long, string?),TreeQueryProviderBase.ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, FilterExpression?),TreeQueryProviderBase.ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?),TreeQueryProviderBase.ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?),TreeQueryProviderBase.ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?),TreeQueryProviderBase.ExecuteOptimizedWhereHasAncestor<TProps>(TreeQueryContext<TProps>, TreeFilter),TreeQueryProviderBase.ExecuteOptimizedWhereHasDescendant<TProps>(TreeQueryContext<TProps>, TreeFilter),TreeQueryProviderBase.ExecuteTreeCountAsync<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.ExecuteTreeDeleteAsync(long[]),TreeQueryProviderBase.ExecuteTreeGroupedAggregateAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>),TreeQueryProviderBase.ExecuteTreeGroupedWindowQueryAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>),TreeQueryProviderBase.ExecuteTreeToListAsync<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.ExecuteTreeWindowQueryAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?),TreeQueryProviderBase.ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, int?, int?),TreeQueryProviderBase.ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?),TreeQueryProviderBase.GetFilterJsonAsync<TProps>(QueryContext<TProps>),TreeQueryProviderBase.GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?),TreeQueryProviderBase.GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?),TreeQueryProviderBase.GetIdsWithAncestorsAsync<TProps>(List<long>),TreeQueryProviderBase.GetOptimizableHasAncestorFilter<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.GetOptimizableHasDescendantFilter<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.GetSchemeAsync(long),TreeQueryProviderBase.GetSqlPreviewAsync<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.GetSqlPreviewAsync<TProps>(QueryContext<TProps>),TreeQueryProviderBase.GetTreeGroupBySqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>),TreeQueryProviderBase.GetTreeGroupedWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>),TreeQueryProviderBase.GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?),TreeQueryProviderBase.GetWindowSqlPreviewAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?),TreeQueryProviderBase.LoadObjectsByIdsAsync(List<long>, int?),TreeQueryProviderBase.LoadObjectsByIdsAsync<TProps>(List<long>, int?),TreeQueryProviderBase.ShouldUseLazyLoading<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.ShouldUseLazyLoading<TProps>(QueryContext<TProps>),PostgresTreeQueryProvider.CreateFilterParser(),PostgresTreeQueryProvider.CreateQueryProvider(),PostgresTreeQueryProvider.CreateTreeQueryable<TProps>(TreeQueryContext<TProps>)

Methods

CreateFilterParser()

Pro: Uses ProFilterExpressionParser with arithmetic and function support

protected override ProFilterExpressionParser CreateFilterParser()

ExecuteAggregateAsync(long, string, AggregateFunction, string?)

Execute aggregation on EAV field (SQL strategy for simple fields).

public override Task<decimal?> ExecuteAggregateAsync(long schemeId, string fieldPath, AggregateFunction function, string? filterJson = null)

ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, string?)

Execute batch aggregation (multiple fields in one query).

public override Task<AggregateResult> ExecuteAggregateBatchAsync(long schemeId, IEnumerable<AggregateRequest> requests, string? filterJson = null)

ExecuteArrayGroupedAggregateAsync(long, string, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?)

Execute GroupBy aggregation on array (SQL function aggregate_array_grouped).

public override Task<JsonDocument?> ExecuteArrayGroupedAggregateAsync(long schemeId, string arrayPath, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, string? filterJson = null)

ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?)

Execute GroupBy aggregation (SQL function aggregate_grouped).

public override Task<JsonDocument?> ExecuteGroupedAggregateAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, string? filterJson = null)

ExecuteTreeAggregateAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<AggregateRequest>)

Execute tree aggregation with CTE.

public Task<Dictionary<string, decimal?>> ExecuteTreeAggregateAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<AggregateRequest> aggregations) where TProps : class, new()

ExecuteTreeCountAsync<TProps>(TreeQueryContext<TProps>)

⚡ Pro Override: Tree Count via CTE + PVT.

protected override Task<int> ExecuteTreeCountAsync<TProps>(TreeQueryContext<TProps> context) where TProps : class, new()

ExecuteTreeGroupByAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>)

Execute GROUP BY on tree with CTE.

public Task<string> ExecuteTreeGroupByAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations) where TProps : class, new()

ExecuteTreeGroupedAggregateAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>)

ITreeQueryProvider implementation: Execute GROUP BY with tree context.

public override Task<JsonDocument?> ExecuteTreeGroupedAggregateAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations) where TProps : class, new()

ExecuteTreeGroupedWindowQueryAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>)

Execute Tree GroupBy + Window query.

public override Task<JsonDocument?> ExecuteTreeGroupedWindowQueryAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy) where TProps : class, new()

ExecuteTreeToListAsync<TProps>(TreeQueryContext<TProps>)

⚡ Pro Override: Tree ToList via CTE + PVT.

protected override Task<object> ExecuteTreeToListAsync<TProps>(TreeQueryContext<TProps> context) where TProps : class, new()

ExecuteTreeWindowAsync<TProps>(TreeQueryContext<TProps>, string, string, string, string, string?)

Execute Window Functions on tree with CTE (legacy JSON version).

public Task<string> ExecuteTreeWindowAsync<TProps>(TreeQueryContext<TProps> context, string selectFieldsJson, string windowFunctionsJson, string partitionByJson, string orderByJson, string? frameJson = null) where TProps : class, new()

ExecuteTreeWindowQueryAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?)

Execute Window Functions on tree with CTE (interface implementation).

public override Task<JsonDocument?> ExecuteTreeWindowQueryAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<WindowFieldRequest> selectFields, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? frameJson = null) where TProps : class, new()

ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?)

Execute query with window functions (SQL function query_with_window).

public override Task<JsonDocument?> ExecuteWindowQueryAsync(long schemeId, IEnumerable<WindowFieldRequest> selectFields, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? filterJson = null, string? frameJson = null, int? take = null, int? skip = null)

GetGroupBySqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?)

Returns SQL preview for GroupBy query with tree constraints.

public Task<string> GetGroupBySqlPreviewAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, string? filterJson = null)

GetSchemeAsync(long)

Get scheme by ID (for projections) - delegate to base provider

public override Task<IRedbScheme?> GetSchemeAsync(long schemeId)

GetSqlPreviewAsync<TProps>(TreeQueryContext<TProps>)

Pro: Tree SQL Preview (DRY - uses BuildTreeQuerySqlAsync)

public override Task<string> GetSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context) where TProps : class, new()

GetTreeAggregateSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<AggregateRequest>)

SQL Preview for Tree Aggregate (DRY - same SQL as Execute)

public Task<string> GetTreeAggregateSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<AggregateRequest> aggregations) where TProps : class, new()

GetTreeGroupBySqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>)

SQL Preview for Tree GroupBy (DRY - same SQL as Execute)

public override Task<string> GetTreeGroupBySqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations) where TProps : class, new()

GetTreeGroupedWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>)

SQL preview for Tree GroupBy + Window.

public override Task<string> GetTreeGroupedWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy) where TProps : class, new()

GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?)

SQL Preview for Tree Window (typed interface version).

public override Task<string> GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<WindowFieldRequest> selectFields, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? frameJson = null) where TProps : class, new()

GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, string, string, string, string, string?)

SQL Preview for Tree Window (DRY - same SQL as Execute)

public Task<string> GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, string selectFieldsJson, string windowFunctionsJson, string partitionByJson, string orderByJson, string? frameJson = null) where TProps : class, new()

Constructors