Prefetch table then prefetch multiple from prefetched.

Posts   
 
    
bvalle
User
Posts: 54
Joined: 07-Jun-2006
# Posted on: 11-Oct-2006 19:24:05   

Hello

I have the following table structure

Site-joinsToMany-> Assembly Assembly-joinsToMany->Antenna Assembly-joinsToMany->Component Assembly-joinsToMany->Device

Basically I am pulling a Site and I would like to get all Assemblies, Antennas, Components, and Devices for that one site. I tried two pieces of code that did not work.

This one gives me the problem when fetching, since PrefetchPathComponent is not part of SiteEntity.


PrefetchPath2 siteAndChildren = new PrefetchPath2((int)EntityType.SiteEntity);
siteAndChildren.Add(SiteEntity.PrefetchPathAssembly).SubPath.Add(AssemblyEntity.PrefetchPathAntenna);
siteAndChildren.Add(AssemblyEntity.PrefetchPathComponent);
siteAndChildren.Add(AssemblyEntity.PrefetchPathDevice);

And this one gives me the error that the path already exists when running:


PrefetchPath2 siteAndChildren = new PrefetchPath2((int)EntityType.SiteEntity);
siteAndChildren.Add(SiteEntity.PrefetchPathAssembly).SubPath.Add(AssemblyEntity.PrefetchPathAntenna);
siteAndChildren.Add(SiteEntity.PrefetchPathAssembly).SubPath.Add(AssemblyEntity.PrefetchPathComponent);
siteAndChildren.Add(SiteEntity.PrefetchPathAssembly).SubPath.Add(AssemblyEntity.PrefetchPathDevice);

Is there a way to pull these records starting from Site? I understand that I could pull Assemblies and basicaly prefetch all the others, unfortunatelly my code uses sites as base to travel.

Thank you, Bruno Valle

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 12-Oct-2006 02:51:44   

Give this a try

PrefetchPath2 siteAndChildren = new PrefetchPath2((int)EntityType.SiteEntity);
IPrefetchPathElement2 element = SiteEntity.PrefetchPathAssembly;
element.SubPath.Add(AssemblyEntity.PrefetchPathAntenna);
element.SubPath.Add(AssemblyEntity.PrefetchPathComponent);
element.SubPath.Add(AssemblyEntity.PrefetchPathDevice);
siteAndChildre.Add(element);
bvalle
User
Posts: 54
Joined: 07-Jun-2006
# Posted on: 12-Oct-2006 15:52:22   

Very nice, it worked. The more I use this product the more I am impressed.

Thanks bclubb.