ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,793 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi ,
I want to validate a selected date that does not fall in a list of dates from other table.
Basically when user selects a date from calendar,i need to validate that date is not in list of dates fetched from a table.
How can i acheive this via LINQ query?
Try something like this:
DateTime selected_date = . . .
IEnumerable<DateTime> list_of_dates = . . .
bool is_valid = !list_of_dates.Contains( selected_date );
If the time part is present and must be ignored:
bool is_valid = list_of_dates.All( d => d.Date != selected_date.Date );