I am building a query tool for use by non technical staff to retrieve records from the database.
I have a form with various drop downs which can be selected by the user depending on what they are looking for.
I have come across a problem where my query is returning records that do not match the users selection.
I believe this is only happening when I am querying the joined tables.
I have the following:
results = results.Where(c => c.CustomerEnrollment
.Where(x => x.CustomerCategoryID == CustomerCategoryID)
.Any());
results = results.Where(c => c.CustomerEnrollment
.Where(x => x.StartDate <= DateRangeStart && x.EndDate >= DateRangeStart)
.Any());
This will return results for the correct category but not within the specified date range.
I have also tried:
results = results.Where(c => c.CustomerEnrollment
.Any(x => x.CustomerCategoryID == CustomerCategoryID));