Given the following classes:
public class Nation
{
public string Name { get; set; }
public IEnumerable<City> Cities { get; private set; }
}
public class City
{
public string Name { get; set; }
}
Assume Nation is the aggregate root and so I only have a NationRepository and not a CityRepository (thus Nation is the starting point for Linq queries). To clarify, my starting point would be an IQueryable<Nation> object.
How would I write a query which returns a collection of City objects according to the following logic:
Select all City instances whose Name begins with ‘M’ whose parent Nation‘s name is ‘UK’?
You would do the following: