I am trying to get the list of files (file is an entity) which has the selected services (service is another entity). The file can have many services.
I tried the following statement, but it does not give the correct results:
var _serviceTypes = viewModel.SelectedServiceTypes;
// _serviceTypes is an array of integers
var resultsTemp = repository.Files.Where(f => f.Services.Select(s => s.ServiceTypeID).Intersect(_serviceTypes).Any());
What am I missing?
EDIT:
_serviceTypes in an array of integers: {int[2]}
The files can have many services, each of which as one service type id (integer)
For instance, a file has two services in it: ambulance (service type id: 3) and hospitalization (service type id: 5). I want to get all the files which have both the services in it.
_serviceTypeswhen this runs, and what's inresultsTempafterward?