Class TreeQueryProviderBase

Assembly: redb.Core.dll

Base tree query provider for executing hierarchical LINQ queries via search_tree_objects_with_facets.
Database-specific implementations should inherit and provide ISqlDialect.

public abstract class TreeQueryProviderBase : ITreeQueryProvider, IRedbQueryProvider

Inheritance

ObjectTreeQueryProviderBase

Implements

Derived

Properties

Cache

Metadata cache for this provider (domain-isolated).

public GlobalMetadataCache Cache { get; }

Methods

CheckProOnlyDistinctFeatures<TProps>(QueryContext<TProps>)

Check for Pro-only Distinct features (DistinctBy, DistinctByRedb, DistinctRedb).

protected virtual void CheckProOnlyDistinctFeatures<TProps>(QueryContext<TProps> context) where TProps : class, new()

CreateFacetBuilder()

Creates facet filter builder.

protected virtual IFacetFilterBuilder CreateFacetBuilder()

CreateFilterParser()

Creates filter expression parser. Override for Pro features.

protected abstract IFilterExpressionParser CreateFilterParser()

CreateOrderingParser()

Creates ordering expression parser.

protected virtual IOrderingExpressionParser CreateOrderingParser()

CreateQuery<TProps>(long, long?, bool)

Create new query for specified scheme.

public IRedbQueryable<TProps> CreateQuery<TProps>(long schemeId, long? userId = null, bool checkPermissions = false) where TProps : class, new()

CreateQueryProvider()

Creates query provider for delegation. Override in derived classes.

protected abstract IRedbQueryProvider CreateQueryProvider()

CreateTreeQuery<TProps>(long, long?, bool, long?, int?)

Create tree query with hierarchical constraint support.

public IRedbQueryable<TProps> CreateTreeQuery<TProps>(long schemeId, long? userId = null, bool checkPermissions = false, long? rootObjectId = null, int? maxDepth = null) where TProps : class, new()

CreateTreeQueryable<TProps>(TreeQueryContext<TProps>)

Creates tree queryable instance. Override in derived classes.

protected abstract IRedbQueryable<TProps> CreateTreeQueryable<TProps>(TreeQueryContext<TProps> context) where TProps : class, new()

ExecuteAggregateAsync(long, string, AggregateFunction, FilterExpression?)

Execute single-field aggregation with FilterExpression (Pro version).

public virtual Task<decimal?> ExecuteAggregateAsync(long schemeId, string fieldPath, AggregateFunction function, FilterExpression? filter)

ExecuteAggregateAsync(long, string, AggregateFunction, string?)

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

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

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

Execute batch aggregation with FilterExpression (Pro version).

public virtual Task<AggregateResult> ExecuteAggregateBatchAsync(long schemeId, IEnumerable<AggregateRequest> requests, FilterExpression? filter)

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

Execute batch aggregation (multiple fields in one query).

public virtual 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 virtual Task<JsonDocument?> ExecuteArrayGroupedAggregateAsync(long schemeId, string arrayPath, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, string? filterJson = null)

ExecuteAsync(Expression, Type)

Execute query asynchronously.

public Task<object> ExecuteAsync(Expression expression, Type elementType)

ExecuteDeleteAsync(long, FilterExpression?)

Delete objects by FilterExpression. Delegates to base QueryProvider.

public Task<int> ExecuteDeleteAsync(long schemeId, FilterExpression? filter)

ExecuteDeleteAsync(long, string?)

Delete objects by filter. Delegates to base QueryProvider.

public Task<int> ExecuteDeleteAsync(long schemeId, string? filterJson = null)

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

Execute GroupBy aggregation with FilterExpression (Pro version).

public virtual Task<JsonDocument?> ExecuteGroupedAggregateAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, FilterExpression? filter)

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

Execute GroupBy aggregation (SQL function aggregate_grouped).

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

ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?)

Execute GroupBy with Window Functions with FilterExpression (Pro version).

public virtual Task<JsonDocument?> ExecuteGroupedWindowQueryAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, FilterExpression? filter)

ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?)

Execute GroupBy with Window Functions (ranking, running totals on aggregated data).

public virtual Task<JsonDocument?> ExecuteGroupedWindowQueryAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? filterJson = null)

ExecuteOptimizedWhereHasAncestor<TProps>(TreeQueryContext<TProps>, TreeFilter)

Optimized execution of WhereHasAncestor through logic inversion:

protected Task<List<TreeRedbObject<TProps>>> ExecuteOptimizedWhereHasAncestor<TProps>(TreeQueryContext<TProps> context, TreeFilter hasAncestorFilter) where TProps : class, new()

ExecuteOptimizedWhereHasDescendant<TProps>(TreeQueryContext<TProps>, TreeFilter)

Optimized execution of WhereHasDescendant through logic inversion:

protected Task<List<TreeRedbObject<TProps>>> ExecuteOptimizedWhereHasDescendant<TProps>(TreeQueryContext<TProps> context, TreeFilter hasDescendantFilter) where TProps : class, new()

ExecuteTreeCountAsync<TProps>(TreeQueryContext<TProps>)

Execute COUNT for tree query through search_tree_objects_with_facets

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

ExecuteTreeDeleteAsync(long[])

Delete objects by ID array (cascade with children).

public Task<int> ExecuteTreeDeleteAsync(long[] objectIds)

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

Execute GROUP BY with tree context (CTE for tree traversal).

public virtual 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 GroupBy + Window with tree context.

public virtual 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>)

Execute ToList for tree query through search_tree_objects_with_facets

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

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

Execute Window Functions with tree context.

public virtual 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>, FilterExpression?, string?, int?, int?)

Execute query with window functions with FilterExpression (Pro version).

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

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

GetFilterJsonAsync<TProps>(QueryContext<TProps>)

Returns the JSON filter that will be sent to SQL function (for diagnostics)

public Task<string> GetFilterJsonAsync<TProps>(QueryContext<TProps> context) where TProps : class, new()

GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?)

Get SQL preview for GroupBy + Window query with FilterExpression (Pro version).

public virtual Task<string> GetGroupedWindowSqlPreviewAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, FilterExpression? filter)

GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?)

Get SQL preview for GroupBy + Window query.

public virtual Task<string> GetGroupedWindowSqlPreviewAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? filterJson = null)

GetIdsWithAncestorsAsync<TProps>(List<long>)

Get IDs of all objects and their parents up to root through recursive CTE

public Task<List<long>> GetIdsWithAncestorsAsync<TProps>(List<long> filteredIds) where TProps : class, new()

GetOptimizableHasAncestorFilter<TProps>(TreeQueryContext<TProps>)

Determines if WhereHasAncestor can be optimized through logic inversion

protected TreeFilter? GetOptimizableHasAncestorFilter<TProps>(TreeQueryContext<TProps> context) where TProps : class, new()

GetOptimizableHasDescendantFilter<TProps>(TreeQueryContext<TProps>)

Determines if WhereHasDescendant can be optimized through logic inversion

protected TreeFilter? GetOptimizableHasDescendantFilter<TProps>(TreeQueryContext<TProps> context) where TProps : class, new()

GetSchemeAsync(long)

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

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

GetSqlPreviewAsync<TProps>(QueryContext<TProps>)

Get SQL preview for standard QueryContext (for IRedbQueryProvider compatibility)

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

GetSqlPreviewAsync<TProps>(TreeQueryContext<TProps>)

Returns SQL query for tree search that will be executed (for debugging)

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

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

Get SQL preview for tree GROUP BY query.

public virtual 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>)

Get SQL preview for tree GroupBy + Window.

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

Get SQL preview for tree window query.

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

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

Get SQL preview for window query (for debugging).

public virtual Task<string> GetWindowSqlPreviewAsync(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)

LoadObjectsByIdsAsync(List<long>, int?)

Load full polymorphic objects by ID list via get_object_json function.

public Task<List<ITreeRedbObject>> LoadObjectsByIdsAsync(List<long> objectIds, int? propsDepth = null)

LoadObjectsByIdsAsync<TProps>(List<long>, int?)

Load full objects by ID list via get_object_json function

public Task<List<TreeRedbObject<TProps>>> LoadObjectsByIdsAsync<TProps>(List<long> objectIds, int? propsDepth = null) where TProps : class, new()

ShouldUseLazyLoading<TProps>(QueryContext<TProps>)

Determines if lazy loading should be used for this query.

protected bool ShouldUseLazyLoading<TProps>(QueryContext<TProps> context) where TProps : class, new()

ShouldUseLazyLoading<TProps>(TreeQueryContext<TProps>)

Determines if lazy loading should be used for tree query.

protected bool ShouldUseLazyLoading<TProps>(TreeQueryContext<TProps> context) where TProps : class, new()

Constructors