Class RedbQueryable<TProps>

Namespace: redb.Core.Query
Assembly: redb.Core.dll

Basic implementation of IRedbQueryable

public class RedbQueryable<TProps> : IOrderedRedbQueryable<TProps>, IRedbQueryable<TProps> where TProps : class, new()

Inheritance

ObjectRedbQueryable<TProps>

Implements

Methods

AggregateAsync<TResult>(Expression<Func<RedbObject<TProps>, TResult>>)

Flexible aggregation - choose what to aggregate via Agg.Sum/Avg/Min/Max/Count

public virtual Task<TResult> AggregateAsync<TResult>(Expression<Func<RedbObject<TProps>, TResult>> selector)

AggregateRedbAsync<TResult>(Expression<Func<IRedbObject, TResult>>)

Flexible aggregation ONLY for base IRedbObject fields

public virtual Task<TResult> AggregateRedbAsync<TResult>(Expression<Func<IRedbObject, TResult>> selector)

AllAsync(Expression<Func<TProps, bool>>)

Check if ALL records match condition.

public virtual Task<bool> AllAsync(Expression<Func<TProps, bool>> predicate)

AnyAsync()

Check if any records exist.

public virtual Task<bool> AnyAsync()

AnyAsync(Expression<Func<TProps, bool>>)

Check if any records match condition.

public virtual Task<bool> AnyAsync(Expression<Func<TProps, bool>> predicate)

AverageAsync<TField>(Expression<Func<TProps, TField>>)

Average of field values.

public virtual Task<decimal> AverageAsync<TField>(Expression<Func<TProps, TField>> selector) where TField : struct

AverageRedbAsync<TField>(Expression<Func<IRedbObject, TField>>)

Average value of base IRedbObject field

public virtual Task<decimal> AverageRedbAsync<TField>(Expression<Func<IRedbObject, TField>> selector) where TField : struct

BuildCountExpression()

Builds expression for record count

protected virtual Expression BuildCountExpression()

BuildExpression()

Builds expression for query execution

protected virtual Expression BuildExpression()

BuildFilterJson()

Builds JSON filter from current query context

protected virtual string? BuildFilterJson()

CountAsync()

Count records without loading data.

public virtual Task<int> CountAsync()

DeleteAsync()

Delete objects without loading data.

public virtual Task<int> DeleteAsync()

Distinct()

Get distinct values (by all object fields).

public virtual IRedbQueryable<TProps> Distinct()

DistinctBy<TKey>(Expression<Func<TProps, TKey>>)

DISTINCT ON (field) - one object per unique Props field value.

public virtual IRedbQueryable<TProps> DistinctBy<TKey>(Expression<Func<TProps, TKey>> keySelector)

DistinctByRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

DISTINCT ON (base_field) - one object per unique IRedbObject base field value.

public virtual IRedbQueryable<TProps> DistinctByRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

DistinctRedb()

DISTINCT by IRedbObject base fields (Name, ValueLong, ParentId, etc.) excluding Id.

public virtual IRedbQueryable<TProps> DistinctRedb()

ExtractFieldPath<TField>(Expression<Func<TProps, TField>>)

Extracts field path from lambda expression

protected string ExtractFieldPath<TField>(Expression<Func<TProps, TField>> selector)

ExtractFieldPathRedb<TField>(Expression<Func<IRedbObject, TField>>)

Extracts base field path from IRedbObject expression

protected string ExtractFieldPathRedb<TField>(Expression<Func<IRedbObject, TField>> selector)

FirstOrDefaultAsync()

Get first object or null.

public virtual Task<RedbObject<TProps>?> FirstOrDefaultAsync()

FirstOrDefaultAsync(Expression<Func<TProps, bool>>)

Get first object matching condition, or null.

public virtual Task<RedbObject<TProps>?> FirstOrDefaultAsync(Expression<Func<TProps, bool>> predicate)

GetStatisticsAsync<TField>(Expression<Func<TProps, TField>>)

Get field statistics (Sum, Avg, Min, Max, Count) in one call

public virtual Task<FieldStatistics<TField>> GetStatisticsAsync<TField>(Expression<Func<TProps, TField>> selector) where TField : struct

GroupBy<TKey>(Expression<Func<TProps, TKey>>)

Grouping with aggregations.

public virtual IRedbGroupedQueryable<TKey, TProps> GroupBy<TKey>(Expression<Func<TProps, TKey>> keySelector)

GroupByArray<TItem, TKey>(Expression<Func<TProps, IEnumerable<TItem>>>, Expression<Func<TItem, TKey>>)

Grouping by array elements

public virtual IRedbGroupedQueryable<TKey, TItem> GroupByArray<TItem, TKey>(Expression<Func<TProps, IEnumerable<TItem>>> arraySelector, Expression<Func<TItem, TKey>> keySelector) where TItem : class, new()

GroupByRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Grouping by base IRedbObject fields (id, scheme_id, parent_id, etc.)

public virtual IRedbGroupedQueryable<TKey, TProps> GroupByRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

MaxAsync<TField>(Expression<Func<TProps, TField>>)

Maximum field value.

public virtual Task<TField?> MaxAsync<TField>(Expression<Func<TProps, TField>> selector) where TField : struct

MaxRedbAsync<TField>(Expression<Func<IRedbObject, TField>>)

Maximum value of base IRedbObject field (ValueLong, Key, DateCreate, etc.)

public virtual Task<TField?> MaxRedbAsync<TField>(Expression<Func<IRedbObject, TField>> selector) where TField : struct

MinAsync<TField>(Expression<Func<TProps, TField>>)

Minimum field value.

public virtual Task<TField?> MinAsync<TField>(Expression<Func<TProps, TField>> selector) where TField : struct

MinRedbAsync<TField>(Expression<Func<IRedbObject, TField>>)

Minimum value of base IRedbObject field (ValueLong, Key, DateCreate, etc.)

public virtual Task<TField?> MinRedbAsync<TField>(Expression<Func<IRedbObject, TField>> selector) where TField : struct

OrderBy<TKey>(Expression<Func<TProps, TKey>>)

Sort ascending by Props field.

public virtual IOrderedRedbQueryable<TProps> OrderBy<TKey>(Expression<Func<TProps, TKey>> keySelector)

OrderByDescending<TKey>(Expression<Func<TProps, TKey>>)

Sort descending by Props field.

public virtual IOrderedRedbQueryable<TProps> OrderByDescending<TKey>(Expression<Func<TProps, TKey>> keySelector)

OrderByDescendingRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Sort descending by IRedbObject base fields.

public virtual IOrderedRedbQueryable<TProps> OrderByDescendingRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

OrderByRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Sort ascending by IRedbObject base fields (id, name, date_create, etc.).

public virtual IOrderedRedbQueryable<TProps> OrderByRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

Select<TResult>(Expression<Func<RedbObject<TProps>, TResult>>)

Project fields - return only selected properties.

public virtual IRedbProjectedQueryable<TResult> Select<TResult>(Expression<Func<RedbObject<TProps>, TResult>> selector)

Skip(int)

Skip records.

public virtual IRedbQueryable<TProps> Skip(int count)

SumAsync<TField>(Expression<Func<TProps, TField>>)

Sum of field values.

public virtual Task<decimal> SumAsync<TField>(Expression<Func<TProps, TField>> selector) where TField : struct

SumRedbAsync<TField>(Expression<Func<IRedbObject, TField>>)

Sum of base IRedbObject field values (ValueLong, Key, etc.)

public virtual Task<decimal> SumRedbAsync<TField>(Expression<Func<IRedbObject, TField>> selector) where TField : struct

Take(int)

Limit the number of records.

public virtual IRedbQueryable<TProps> Take(int count)

ThenBy<TKey>(Expression<Func<TProps, TKey>>)

Additional ascending sort by Props field.

public virtual IOrderedRedbQueryable<TProps> ThenBy<TKey>(Expression<Func<TProps, TKey>> keySelector)

ThenByDescending<TKey>(Expression<Func<TProps, TKey>>)

Additional descending sort by Props field.

public virtual IOrderedRedbQueryable<TProps> ThenByDescending<TKey>(Expression<Func<TProps, TKey>> keySelector)

ThenByDescendingRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Additional descending sort by IRedbObject base fields.

public virtual IOrderedRedbQueryable<TProps> ThenByDescendingRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

ThenByRedb<TKey>(Expression<Func<IRedbObject, TKey>>)

Additional ascending sort by IRedbObject base fields.

public virtual IOrderedRedbQueryable<TProps> ThenByRedb<TKey>(Expression<Func<IRedbObject, TKey>> keySelector)

ToFilterJsonAsync()

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

public virtual Task<string> ToFilterJsonAsync()

ToFlatListAsync()

Execute query and get flat list of tree objects.

public virtual Task<List<TreeRedbObject<TProps>>> ToFlatListAsync()

ToListAsync()

Execute query and return list of objects.

public virtual Task<List<RedbObject<TProps>>> ToListAsync()

ToListWithProjectionAsync(HashSet<long>?, bool)

Internal method for optimized loading with structure_ids filter.

protected virtual Task<List<RedbObject<TProps>>> ToListWithProjectionAsync(HashSet<long>? projectedStructureIds, bool skipPropsLoading = false)

ToRootListAsync()

Execute query and get list of root tree nodes.

public virtual Task<List<ITreeRedbObject>> ToRootListAsync()

ToSqlString()

Get SQL representation of query (for debugging).

public virtual string ToSqlString()

ToSqlStringAsync()

Async version of getting SQL (recommended)

public virtual Task<string> ToSqlStringAsync()

ToTreeListAsync()

Execute query and return filtered objects with populated Parent/Children chains.

public virtual Task<List<TreeRedbObject<TProps>>> ToTreeListAsync()

Where(Expression<Func<TProps, bool>>)

Filter by Props fields.

public virtual IRedbQueryable<TProps> Where(Expression<Func<TProps, bool>> predicate)

WhereChildrenOf(IRedbObject)

Direct children of specified object.

public virtual IRedbQueryable<TProps> WhereChildrenOf(IRedbObject parentObject)

WhereChildrenOf(long)

Direct children of specified object.

public virtual IRedbQueryable<TProps> WhereChildrenOf(long parentId)

WhereDescendantsOf(IRedbObject, int?)

All descendants of specified object (recursive).

public virtual IRedbQueryable<TProps> WhereDescendantsOf(IRedbObject ancestorObject, int? maxDepth = null)

WhereDescendantsOf(long, int?)

All descendants of specified object (recursive).

public virtual IRedbQueryable<TProps> WhereDescendantsOf(long ancestorId, int? maxDepth = null)

WhereHasAncestor<TTarget>(Expression<Func<TTarget, bool>>, int?)

Filter by ancestors: find objects that have an ancestor of specified type matching condition.

public virtual IRedbQueryable<TProps> WhereHasAncestor<TTarget>(Expression<Func<TTarget, bool>> ancestorCondition, int? maxDepth = null) where TTarget : class

WhereHasDescendant<TTarget>(Expression<Func<TTarget, bool>>, int?)

Filter by descendants: find objects that have a descendant of specified type matching condition.

public virtual IRedbQueryable<TProps> WhereHasDescendant<TTarget>(Expression<Func<TTarget, bool>> descendantCondition, int? maxDepth = null) where TTarget : class

WhereIn<TValue>(Expression<Func<TProps, TValue>>, IEnumerable<TValue>)

Filter by value in list (WHERE field IN (...)).

public virtual IRedbQueryable<TProps> WhereIn<TValue>(Expression<Func<TProps, TValue>> selector, IEnumerable<TValue> values)

WhereInRedb<TValue>(Expression<Func<IRedbObject, TValue>>, IEnumerable<TValue>)

Filter by IRedbObject base field in list (WHERE _field IN (...)).

public virtual IRedbQueryable<TProps> WhereInRedb<TValue>(Expression<Func<IRedbObject, TValue>> selector, IEnumerable<TValue> values)

WhereLeaves()

Leaf nodes only (objects without children).

public virtual IRedbQueryable<TProps> WhereLeaves()

WhereLevel(Expression<Func<int, bool>>)

Filter by tree level with comparison operator.

public virtual IRedbQueryable<TProps> WhereLevel(Expression<Func<int, bool>> levelCondition)

WhereLevel(int)

Filter by tree level.

public virtual IRedbQueryable<TProps> WhereLevel(int level)

WhereRedb(Expression<Func<IRedbObject, bool>>)

Filter by base object fields (Id, Name, ParentId, etc.).

public virtual IRedbQueryable<TProps> WhereRedb(Expression<Func<IRedbObject, bool>> predicate)

WhereRoots()

Root elements only (parent_id IS NULL).

public virtual IRedbQueryable<TProps> WhereRoots()

WithLazyLoading(bool)

Enable/disable lazy loading of Props for this query.

public virtual IRedbQueryable<TProps> WithLazyLoading(bool enabled = true)

WithMaxDepth(int)

Configure maximum tree search depth.

public virtual IRedbQueryable<TProps> WithMaxDepth(int depth)

WithMaxRecursionDepth(int)

Configure maximum recursion depth for complex queries ($and/$or/$not).

public virtual IRedbQueryable<TProps> WithMaxRecursionDepth(int depth)

WithPropsDepth(int)

Configure maximum depth for loading nested RedbObject in Props.

public virtual IRedbQueryable<TProps> WithPropsDepth(int depth)

WithWindow(Action<IWindowSpec<TProps>>)

Query with window functions.

public virtual IRedbWindowedQueryable<TProps> WithWindow(Action<IWindowSpec<TProps>> windowConfig)

Constructors