Accessing child collection in query
- by Gokul
I am populating a list using
List<Country> countries = new List<Country>
{
new Country()
{
CountryID = "US",
City = new List<City> {
new City()
{
CountryID = "US", CityName="dfdsf", sqkm = 2803
}
}
};
and so on
How to access sqkm in the following query?
var countryQuery = countries
.Select(c => new { Id = c.CountryId, Area = c.City.sqkm???});
c.city.sqkm gives compilation error...how to modify query