Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Lambda declaration
Message
From
21/11/2014 11:33:57
John Baird
Coatesville, Pennsylvania, United States
 
General information
Forum:
ASP.NET
Category:
LINQ
Environment versions
Environment:
C# 5.0
OS:
Windows 7
Network:
SAMBA Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01611296
Message ID:
01611297
Views:
61
>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....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform