Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Newbie to Linq
Message
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Titre:
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01605340
Message ID:
01605476
Vues:
48
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
                     // Execute the query
Regards,
Peter J. Kane



Pete
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform