My data is owner, location, date, charge, payment, the plan is to get a list of owners, each having a location, and the Sum OwnerTotal (charge - payamount)
| OwnerId | Location | Charge | PayAmount |
| 1 | Loc 1 | 100 | 0 |
| 1 | Loc 1 | 60 | 50 |
| 1 | Loc 1 | 80 | 0 |
| 2 | Loc 2 | 100 | 0 |
| 2 | Loc 2 | 80 | 0 |
| 1 | Loc 1 | 190 |
| 2 | Loc 2 | 180 |
[Route("ByProviderBilled")]
[HttpGet]
public async Task<ActionResult<List<TxnsByProvider>>> GetByProviderBilled(int id, bool isbilled) => await context.Transactions
.Where(p => p.ProviderId == id && p.IsBilled == isbilled).GroupBy(x => x.OwnerBillToId)
.Select(txn => new TxnsByProvider
{
ownerBillToId = (int)txn.First().OwnerBillToId,
Location = txn.First().OwnerLocation.Location,
OName = txn.First().OwnerBillTo.Oname,
OwnerTotal = (decimal)txn.Sum(o => o.Charge - o.PayAmount)
})
.OrderByDescending(t => t.OName)
.ToListAsync();.Select(s => s.OwnerBillToId)
.First()' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync
Really don't want to take Transactions into memory as is suggested, so maybe there is a different approach I can take without First()?