My schema is simple:
Models can be part of many Areas.
Areas can have many Models withing them.
Models and areas are related m:n via the AreaMembers Table.
I am trying to load all the data into two collections: ModelEntities, AreaEnties.
I am using the entitycache.
My code look like:
1 private void fillAll()
2 {
3 ModelEntities = getProvider().ModelProvider.GetAll();
4 loadModelRelatedEntities(ModelEntities);
5 AreaEntities = getProvider().AreaProvider.GetAll();
6 loadAreaRelatedEntities(AreaEntities);
7 modelBindingSource.DataSource = ModelEntities;
8 areaBindingSource.DataSource = AreaEntities;
9 }
10 private void loadModelRelatedEntities(IMV.ModelListDAL.Entities.TList<Model> ModelEntities)
11 {
12 foreach (Model m in ModelEntities)
13 {
14 m.AreaMemberCollection = getProvider().AreaMemberProvider.GetByModel_id(m.Id);
15 m.AreaCollection_From_AreaMember =
16 getProvider().AreaProvider.GetBymodel_idFromAreaMember(m.Id);
17 }
18 }
19 private void loadAreaRelatedEntities(IMV.ModelListDAL.Entities.TList<Area> AreaEntities)
20 {
21 foreach (Area a in AreaEntities)
22 {
23 a.AreaMemberCollection = getProvider().AreaMemberProvider.GetByArea_id(a.Id);
24 a.ModelCollection_From_AreaMember =
25 getProvider().ModelProvider.GetByarea_idFromAreaMember(a.Id);
26 }
27 }
You may be wondering why I didn't use deepload with the false option for
recursive fetching... well I was getting a stack overflow exception so since
deepload had way to much code to wade through I just wrote this by hand.
Problem is that it also overflows. Any ideas why?