Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Lambda declaration
Message
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:
01611300
Views:
45
>Hi John, I figured it out, ITariffDataImport is the interface my class implements and the string is one of three class properties that I possibly want to group by. I had to use parentheses instead of angle brackets after Func because of UT rendering limitations
>
>
>
>Func(ITariffDataImport, string) grp = null;
>                
>                if (App.ImportSettings.RemoveDuplicates)
>                {
>                    Console.WriteLine("Removing duplicate tariffs...");
>                    
>                    if (App.tariffType == TariffType.BTInternational)
>                        grp = s => s.Destination;
>                    else
>                        if (App.tariffType == TariffType.BTNational118)
>                            grp = s => s.ChargeBand;
>                        else
>                            if (App.tariffType == TariffType.BTNationalIP)
>                                grp = s => s.Service;
>
>                    xlistint.Data = xlistint.Data.GroupBy(grp).Select(s => s.First()).ToList();
>
>
>nice and clean I think.

Neat - but a switch on TarriffType looks cleaner (and more extensible)?:
        switch (App.tarriffType)
        {
            case TarriffType.BTInternational:
                grp = s => s.Destination;
                break;
            case TarriffType.BTNational118:
                 grp = s => s.ChargeBand;
                break;
            case TarriffType.BTNationalIP:
                grp = s => s.Service;
                break;
        }
BTW I think that although UT shows an error with the angle brackets on preview it actually works when you send .....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform