Table of Contents

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

TEntity

The 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

keySelector Expression<Func<TEntity, TKey>>

The grouping key selector.

resultSelector Expression<Func<IGrouping<TKey, TEntity>, TResult>>

The per-group projection (g => new { g.Key, Total = g.Sum(x => x.Total) }).

having Expression<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 &&/||/!.

options QueryOptions<TEntity>

Optional query shaping — the filter applies before grouping; sorting does not apply.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IReadOnlyList<TResult>>

One projected result per group.

Type Parameters

TKey

The key type (a member, or an anonymous composite of members).

TResult

The projected result type (anonymous or member-init).