Interface IGroupedReadRepository<TEntity>
- Namespace
- eQuantic.Core.Data.Repository.Read
- Assembly
- eQuantic.Core.Data.dll
A read repository that groups on the store: the key and the aggregate projection render to a
native GROUP BY, and only the grouped rows travel. The projection is typed LINQ restricted to the
shapes a store can aggregate server-side — g.Key, g.Count(),
g.Sum/Min/Max/Average(x => x.Member); anything else is rejected with the supported shapes.
Providers opt in.
public interface IGroupedReadRepository<TEntity> where TEntity : class
Type Parameters
TEntityThe entity type.
Methods
GroupByAsync<TKey, TResult>(Expression<Func<TEntity, TKey>>, Expression<Func<IGrouping<TKey, TEntity>, TResult>>, Expression<Func<IGrouping<TKey, TEntity>, bool>>?, QueryOptions<TEntity>?, CancellationToken)
Groups the matching elements by keySelector and projects each group with
resultSelector — computed on the store.
Task<IReadOnlyList<TResult>> GroupByAsync<TKey, TResult>(Expression<Func<TEntity, TKey>> keySelector, Expression<Func<IGrouping<TKey, TEntity>, TResult>> resultSelector, Expression<Func<IGrouping<TKey, TEntity>, bool>>? having = null, QueryOptions<TEntity>? options = null, CancellationToken cancellationToken = default)
Parameters
keySelectorExpression<Func<TEntity, TKey>>The grouping key selector.
resultSelectorExpression<Func<IGrouping<TKey, TEntity>, TResult>>The per-group projection (
g => new { g.Key, Total = g.Sum(x => x.Total) }).havingExpression<Func<IGrouping<TKey, TEntity>, bool>>Optional predicate over each group — a native
HAVING(g => g.Sum(x => x.Total) > 100 && g.Count() >= 2): comparisons of aggregates or key members, combined with&&/||/!.optionsQueryOptions<TEntity>Optional query shaping — the filter applies before grouping; sorting does not apply.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IReadOnlyList<TResult>>
One projected result per group.
Type Parameters
TKeyThe key type (a member, or an anonymous composite of members).
TResultThe projected result type (anonymous or member-init).