Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for advice on how to search for a holiday
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01336267
Message ID:
01336293
Views:
15
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;
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform