I am trying to use to linq to retrieve some data, and creating my queries dynamically with where clauses added to an IQueryable object.
The problem I am running into is filtering for days of the week. In the table, I have a datetime of a call. I want to be able to pick certain days of the week to filter for. I have those days of the week stored as strings in a string array. I was then trying to do a contains statement to see if the day of the week, based on the date time is one of those in the array.
My code is below
matches = matches.Where(CallRequest => CallRequest.dTimestamp != null && f.PrintDays.Contains(Convert.ToDateTime(CallRequest.dTimestamp).DayOfWeek.ToString()));
f.PrintDays is the string, with the week days stored as "Sunday","Monday" etc.
I use the Convert statement, since it is a ?DateTime in the table, but by that point I have already verified that it is not null.
If anyone has any ideas, or maybe this isn't even possible, let me know.