Here is my group by query
var query = (
from fee in _walletRepository.Table
group fee by fee.PartyId into groupResult
select new
{
partyId = groupResult.Select(x => x.PartyId),
Balance = groupResult.Sum(f => f.Receipt > 0 ? f.Receipt : 0) - groupResult.Sum(f => f.Payment > 0 ? f.Payment : 0)
}).OrderByDescending(x => x.Balance);
var tmp = await query.ToPagedListAsync(pageIndex, pageSize);
return new PagedList<OGSWallet>(tmp.Select(x => new OGSWallet
{
PartyId = Convert.ToInt32(x.partyId),
AvailableBalance = x.Balance
}).ToList(), tmp.PageIndex, tmp.PageSize, tmp.TotalCount);
Whenever I run the query, it throws error in query following line var tmp = await query.ToPagedListAsync(pageIndex, pageSize);
? Error : LinqToDB.LinqToDBException: You should explicitly specify selected fields for server-side GroupBy() call or add AsEnumerable() call before GroupBy() to perform client-side grouping.
Is there any idea is it query problem or any other problem?
Problem with line
partyId = groupResult.Select(x => x.PartyId).PartyIdis the key of the grouping and should be retrieved fromgroupResult.Key