Your previous attempt with the two queries might have worked then if it was brought locally (AsEnumerable or ToList) before the grouping. As is, it was left as an IQueryable so the group by was probably executed on the server as a new query rather than using the previous results. The GroupBy probably also forced a new ordering.
Good call Rob I tried Vivs code ( only slightly modified by adding ToList()) and it worked as expected - I think we've all learnt something here - thank you all for your help. Here are the two queries that work.
var q = Context.invoices // Start at invoices because this is the list we really care about
.Include(inv => inv.client) // Eager load the client so it doesn't require additional queries
.Where(inv => inv.invoiceamount >= InvoiceAmount)
.OrderByDescending(x => x.invoiceamount).ToList();
var results = q.GroupBy(inv => inv.client); // Group results by client so we can loop through the clients
Regards,
Peter J. Kane
Pete