Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Do This With Linq
Message
De
24/05/2010 21:05:23
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Divers
Thread ID:
01465788
Message ID:
01465801
Vues:
69
>I have a collection of objects called Groups which have a Sequence property. I'd like to get back the highest sequence. How can I do
>this with Linq?
>
>I tried this, but it doesn't recognize Max:
>
>
>var group = Manager.Root.Groups.Max(x => x.Sequence);
>
>
>I thought this was it http://msdn.microsoft.com/en-us/library/system.linq.enumerable.max.aspx
>
>but I guess I'm wrong.

I don't have intellisense right now, but I think you want OrderByDescending(x => x.Sequence) coupled with Take(1).
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform