- EF Core 3.1.8
- Npgsql.EntityFrameworkCore.PostgreSQL 3.1.4
I implemented following query which must retirn all comment's group by date and after time.
var commentsOnPage = await _repository.GetAll()
.OrderByDescending(c => c.Date.Date)
.ThenBy(c => c.Date.TimeOfDay)
.Skip(pageSize * pageIndex)
.Take(pageSize)
.ToListAsync();
public class CommentRepository : GenericRepository<Comment>, ICommentRepository
{
private readonly AppDbContext _dbContext;
public CommentRepository(AppDbContext dbContext) : base(dbContext)
{
_dbContext = dbContext;
}
public IQueryable<Comment> GetAll() => ((AppDbContext)_dbContext).Comments.AsQueryable();
}
Return error:
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: The LINQ expression 'DbSet<Comment>
.OrderByDescending(c => c.Date.Date)
.ThenBy(c => c.Date.TimeOfDay)' could not be translated.