Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Lambda declaration
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Titre:
Lambda declaration
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:
01611296
Vues:
64
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();
Regards,
Peter J. Kane



Pete
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform