Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GroupBy for IQuery #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions URF.Core.Abstractions/IQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public interface IQuery<TEntity> where TEntity : class
IQuery<TEntity> Take(int take);
IQuery<TEntity> ThenBy(Expression<Func<TEntity, object>> thenBy);
IQuery<TEntity> ThenByDescending(Expression<Func<TEntity, object>> thenByDescending);
IQuery<TEntity> GroupBy(Expression<Func<TEntity, object>> groupBy);
Task<int> CountAsync(CancellationToken cancellationToken = default);
Task<TEntity> FirstOrDefaultAsync(CancellationToken cancellationToken = default);
Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
Expand All @@ -26,7 +27,6 @@ public interface IQuery<TEntity> where TEntity : class
Task<IEnumerable<TEntity>> SelectSqlAsync(string sql, object[] parameters, CancellationToken cancellationToken = default);
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
Task<bool> AnyAsync(CancellationToken cancellationToken = default);
Task<bool> AllAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);

Task<bool> AllAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
}
}
}
3 changes: 3 additions & 0 deletions URF.Core.EF/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public virtual IQuery<TEntity> ThenByDescending(Expression<Func<TEntity, object>
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
=>Set(q => q._orderedQuery.ThenByDescending(thenByDescending));

public virtual IQuery<TEntity> GroupBy(Expression<Func<TEntity, object>> groupBy)
=> Set(q => q._query.GroupBy(groupBy));

public virtual async Task<int> CountAsync(CancellationToken cancellationToken = default )
=> await _query.CountAsync(cancellationToken);

Expand Down