I have the following Linq query
public static List<string> selectedLocations = new List<string>();
// I then populate selectedLocations with a number of difference strings, each
// corresponding to a valid Location
viewModel.people = (from c in db.People
select c)
.OrderBy(x => x.Name)
.ToList();
// Here I'm basically filtering my dataset to include Locations from
// my array of selectedLocations
viewModel.people = from c in viewModel.people
where (
from a in selectedLocations
where a == c.Location.Name
select a
).Any()
select c;
This works really well as each Person record can have a single Location.
My question is how do I change this query if a Person can have a one-many relationship with Location? So a Person can have 2 Locations as an example, what do I need to change this line to?
where a == c.Location.Name
Thanks!