ASP.net MVC3 entities, don't know how to count
- by Spedax
I have 2 tables, 1 with countries, 1 with states.
The states table has a column with Population.
I'm using entities and I have created a List of states for the countries
public class TblCountries
{
//Entities for my table country
...
public List<tblStates> States { get; set; }
}
So now I can for example List all the states that belong to a country.
Now what I want to do is count the population, so I can show the population that of an entire country.
I tried using in my view
@foreach (var item in Model.Countries) {
@Html.DisplayFor(modelItem => item.States.Count<population>)
}
But this doesn't work, anyone know how to do this?
Thanks in advanced!