Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie to Linq
Message
General information
Forum:
ASP.NET
Category:
LINQ
Title:
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01605340
Message ID:
01605435
Views:
57
Hmm. Out of curiosity do you get the correct order after the OrderByDescending. i.e is the result of q OK using the below?:
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)// Filter results);

var result =  q.GroupBy(inv => inv.client) // Group results by client so we can loop through the clients
                    .ToList()); // Execute the query
BTW There's an interesting side effect of GroupBy in this situation : The clients will be listed in descending order by their largest invoice - which is probably not what you want.....


>Hi Viv, here's some sample output from my query
>
>Query
>
>var results = (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)// Filter results
>                    .GroupBy(inv => inv.client) // Group results by client so we can loop through the clients
>                    .ToList()); // Execute the query
>
>
>Sample output
>
>Company: Steve Hall Fire Protection (id: 8)
>	 Invoice reference: PJK\Steve Hall Fire Prevention\30-06-2014-0007
>		 Invoice date: 30/06/2014
>		 Invoice amount: £20,000,000.00
>		 Charge type: Daily Rate
>	 Invoice reference: PJK\Steve Hall Fire Prevention\30-06-2014-0008
>		 Invoice date: 30/06/2014
>		 Invoice amount: £20,000,000.00
>		 Charge type: Daily Rate
>	 Invoice reference: PJK\Steve Hall Fire Prevention\27-06-2014-0003
>		 Invoice date: 27/06/2014
>		 Invoice amount: £6,000,000.00
>		 Charge type: Daily Rate
>	 Invoice reference: PJK\Steve Hall Fire Prevention\30-06-2014-0005
>		 Invoice date: 30/06/2014
>		 Invoice amount: £20,000,000.00
>		 Charge type: Daily Rate
>	 Invoice reference: PJK\Steve Hall Fire Prevention\30-06-2014-0006
>		 Invoice date: 30/06/2014
>		 Invoice amount: £20,000,000.00
>		 Charge type: Daily Rate
>
>
>as you can see there's a 6,000,000.00 snuck in the middle - the same thing happens on all my test data.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform