Accessing child collection in query
Posted
by Gokul
on Stack Overflow
See other posts from Stack Overflow
or by Gokul
Published on 2010-05-20T11:53:18Z
Indexed on
2010/05/20
12:00 UTC
Read the original article
Hit count: 195
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
© Stack Overflow or respective owner