LINQ query to navigate an object hierachy

Posted by TesterTurnedDeveloper on Stack Overflow See other posts from Stack Overflow or by TesterTurnedDeveloper
Published on 2010-03-18T04:12:37Z Indexed on 2010/03/18 4:21 UTC
Read the original article Hit count: 124

Filed under:
|

Let's say I have an object graph of Countries / States / Cities, like below:

public class City
{
    public string Name { get; set; }
}

public class State
{
    public List<City> Cities { get; set; }
}

public class Country
{
    public List<State> States { get; set; }
}

Is there a simple way to query a List<Country> to get all the cities?

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ