i am new in LINQ so i have been following some tutorials and official docs like How to: Map Database Relationships on Developer Network.
I am performing this:
1) Got two classes Locality and Region, there's a one to many relation between this "tables" so than one Region has multiple Localities. I mapped the association like this:
Region:
private EntitySet<City> _cities = new EntitySet<City>();
[Association(Storage = "_cities", ThisKey = "RegionId", OtherKey = "RegionId")]
public EntitySet<City> Cities
{
get { return _cities; }
set { _cities.Assign(value); }
}
The Region has two more fields RegionId and Name. City has two fields too: CityId, Name (beside the RegionId foreign key of course).
Now i populate the database. So i am able to select all cities using a query like the following:
var city = from City cities in db.cities
select cities;
And i can see all the properties belonging to City Entity. But when i perform this query:
var regiones = from Region region in db.regions
select region;
I only can access to RegionId,Name because the Cities EntitySet is always empty. I dont now what i am doing wrong, so i hope some of you could give me a hand.