Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looking for advice on how to search for a holiday
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01336267
Message ID:
01336293
Vues:
14
Hi,

>I've just started looking into converting our VFP app over to .NET and have a question on how best to replicate a specific routine from our current app.
>
>We have a holiday table that contains records for each holiday, for each corresponding country in our country table. Right now, our routine accepts a date and an array of country codes that we loop through. For each country code in the loop, we seek the holiday table to see if the country code + date record exists. If so, then we have a holiday.
>
>For C#, I'm not sure which approach to use (i.e. arrays, datasets/rows, etc). I think it would be more efficient to send a select command to the database to see if any holiday records exist with a combination of the date and any of the passed countries - a record count > 0 would give me the result I need. I just don't know how to go about this since I'm a total n00b. ;)
>
>Any help to point me in the right direction would be greatly appreciated.

How about Linq. Something like:
            List<string> CountryCodes = new List<string>();
 
            //Some way of populating with countries of interest:
            CountryCodes.Add("US");
            CountryCodes.Add("UK");

            var a = from s in DataContext.HolidayDates
                    where CountryCodes.Contains(s.CountryCode)
                        select s;
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform