Path: redb/redb.Core/Query/IRedbProjectedQueryable.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Query/IRedbProjectedQueryable.cs ---- using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; namespace redb.Core.Query; /// /// Interface for LINQ query projections in REDB. /// public interface IRedbProjectedQueryable { /// /// Additional filtering of projected results. /// IRedbProjectedQueryable Where(Expression> predicate); /// /// Sort projected results. /// IRedbProjectedQueryable OrderBy(Expression> keySelector); /// /// Sort projected results descending. /// IRedbProjectedQueryable OrderByDescending(Expression> keySelector); /// /// Adds a key to the ordering started by OrderBy or OrderByDescending. /// IRedbProjectedQueryable ThenBy(Expression> keySelector) => throw new NotSupportedException($"{GetType().Name} does not implement ThenBy."); /// /// Adds a descending key to the ordering started by OrderBy or OrderByDescending. /// IRedbProjectedQueryable ThenByDescending(Expression> keySelector) => throw new NotSupportedException($"{GetType().Name} does not implement ThenByDescending."); /// /// Limit number of results. /// IRedbProjectedQueryable Take(int count); /// /// Skip results. /// IRedbProjectedQueryable Skip(int count); /// /// Distinct values. /// IRedbProjectedQueryable Distinct(); /// /// Execute query and get list of results. /// Task> ToListAsync(CancellationToken cancellationToken = default); /// /// Count results. /// Task CountAsync(CancellationToken cancellationToken = default); /// /// Get first result or default value. /// Task FirstOrDefaultAsync(CancellationToken cancellationToken = default); /// /// Get projection info including SQL function and structure_ids /// Task GetProjectionInfoAsync(CancellationToken cancellationToken = default); } /// /// Extension methods for Task<IRedbProjectedQueryable<T>> to avoid double await. /// public static class RedbProjectedQueryableTaskExtensions { public static async Task> Where( this Task> queryTask, Expression> predicate) { var query = await queryTask; return query.Where(predicate); } public static async Task> OrderBy( this Task> queryTask, Expression> keySelector) { var query = await queryTask; return query.OrderBy(keySelector); } public static async Task> OrderByDescending( this Task> queryTask, Expression> keySelector) { var query = await queryTask; return query.OrderByDescending(keySelector); } public static async Task> ThenBy( this Task> queryTask, Expression> keySelector) { var query = await queryTask; return query.ThenBy(keySelector); } public static async Task> ThenByDescending( this Task> queryTask, Expression> keySelector) { var query = await queryTask; return query.ThenByDescending(keySelector); } public static async Task> Take( this Task> queryTask, int count) { var query = await queryTask; return query.Take(count); } public static async Task> Skip( this Task> queryTask, int count) { var query = await queryTask; return query.Skip(count); } public static async Task> Distinct( this Task> queryTask) { var query = await queryTask; return query.Distinct(); } public static async Task> ToListAsync( this Task> queryTask, CancellationToken cancellationToken = default) { var query = await queryTask; return await query.ToListAsync(cancellationToken); } public static async Task CountAsync( this Task> queryTask, CancellationToken cancellationToken = default) { var query = await queryTask; return await query.CountAsync(cancellationToken); } public static async Task FirstOrDefaultAsync( this Task> queryTask, CancellationToken cancellationToken = default) { var query = await queryTask; return await query.FirstOrDefaultAsync(cancellationToken); } }