I have a list of objects (Locations). Every location can have multiple categories. I have a list of integers (CategoryId's). Based on that I need to filter locations:
List<int> categoriesToLoad = new List<int>();
// fill list
var allLocations = locationRepository.GetLocations().Where(...
var filteredLocations = from m in model
where categoriesToLoad.Contains(m.LocationCategories.FirstOrDefault() == null ? -1 : m.LocationCategories.FirstOrDefault().PlaceCategoryId)
select m;
This works only for one category, I don't know how to fix code to compare all categories that are attached to location.
Anystackoverflow.com/a/1757244/381422