Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Lambda declaration
Message
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:
01611300
Vues:
44
>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 .....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform