Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Lambda declaration
Message
De
21/11/2014 11:33:57
John Baird
Coatesville, Pennsylvanie, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
C# 5.0
OS:
Windows 7
Network:
SAMBA Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01611296
Message ID:
01611297
Vues:
60
>Hi All, I have a generic List property in my class called Data and depending on certain conditions want to apply a groupby at the end of processing, this is how I currently do it and it works fine.
>
>
>
>
>if(SomeCondition)
>    Data = Data.GroupBy(g => g.Destination).Select(s => s.First()).ToList();
>else
>    Data = Data.GroupBy(g => g.DialCode).Select(s => s.First()).ToList();
>
>// Is there a way I can define a Func<> or something to replace this ?
>
>Func< "What do I put here"> grouper = "What do I put here";
>// so I can say
>
>Data = Data.GroupBy(grouper).Select(s => s.First()).ToList();
>
We used expression trees to do custom lambdas... I'll be interested in seeing what others come up with....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform