Prefetch help

Posts   
 
    
erichar11
User
Posts: 268
Joined: 08-Dec-2003
# Posted on: 09-Apr-2005 17:05:07   

Testing out prefetch functionality and I'm doing the following:


    [Test]
        public void PrefetchOrganizationPageTest()
        {

            int orgPageId = 0;
            IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.OrganizationPageEntity);
            
            prefetch.Add(OrganizationPageEntity.PrefetchPathPageType).SubPath.Add(PageTypeEntity.PrefetchPathModule);
            prefetch.Add(OrganizationPageEntity.PrefetchPathPageType).SubPath.Add(PageTypeEntity.PrefetchPathDashboard);
            

            OrganizationPageEntity page = new OrganizationPageEntity(orgPageId);
            DataAccessAdapter adapter = new DataAccessAdapter();
            adapter.FetchEntity(page, prefetch);

However, only the last prefetch add statement is executed. It seems as the first one is skipped completely (I can comment out the second one and the first prefetch.add will work). I'm sure I'm not doing this correctly when attempting to add multiple entities to an object graph.

Just to clarify, I want to add multiple entities to the object graph

OrgPage -> PageType -> PageTypeModules (First prefetch.Add) OrgPage -> PageType -> PageTypeDashboards (Second prefetch.Add)

Both PageTypeModules and PageTypeDashboards are mxn relations.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 09-Apr-2005 18:23:19   

erichar11 wrote:

Testing out prefetch functionality and I'm doing the following:


    [Test]
        public void PrefetchOrganizationPageTest()
        {

            int orgPageId = 0;
            IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.OrganizationPageEntity);
            
            prefetch.Add(OrganizationPageEntity.PrefetchPathPageType).SubPath.Add(PageTypeEntity.PrefetchPathModule);
            prefetch.Add(OrganizationPageEntity.PrefetchPathPageType).SubPath.Add(PageTypeEntity.PrefetchPathDashboard);
            

            OrganizationPageEntity page = new OrganizationPageEntity(orgPageId);
            DataAccessAdapter adapter = new DataAccessAdapter();
            adapter.FetchEntity(page, prefetch);

However, only the last prefetch add statement is executed. It seems as the first one is skipped completely (I can comment out the second one and the first prefetch.add will work). I'm sure I'm not doing this correctly when attempting to add multiple entities to an object graph.

Just to clarify, I want to add multiple entities to the object graph

OrgPage -> PageType -> PageTypeModules (First prefetch.Add) OrgPage -> PageType -> PageTypeDashboards (Second prefetch.Add)

Both PageTypeModules and PageTypeDashboards are mxn relations. Thanks

Standard mistake wink

You add the OrganizationPageEntity.PrefetchPathPageType node twice.

Instead of:


prefetch.Add(OrganizationPageEntity.PrefetchPathPageType).SubPath.Add(PageTypeEntity.PrefetchPathModule);
prefetch.Add(OrganizationPageEntity.PrefetchPathPageType).SubPath.Add(PageTypeEntity.PrefetchPathDashboard);

do:


PrefetchPathElement2 pageTypeNode = prefetch.Add(OrganizationPageEntity.PrefetchPathPageType);
pageTypeNode.SubPath.Add(PageTypeEntity.PrefetchPathModule);
pageTypeNode.SubPath.Add(PageTypeEntity.PrefetchPathDashboard);

Frans Bouma | Lead developer LLBLGen Pro
erichar11
User
Posts: 268
Joined: 08-Dec-2003
# Posted on: 10-Apr-2005 07:24:51   

thanks, I new it would be simple

mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 12-Jun-2006 23:06:10   

Otis wrote:

do:


PrefetchPathElement2 pageTypeNode = prefetch.Add(OrganizationPageEntity.PrefetchPathPageType);
pageTypeNode.SubPath.Add(PageTypeEntity.PrefetchPathModule);
pageTypeNode.SubPath.Add(PageTypeEntity.PrefetchPathDashboard);

Do you need to add the PageTypeNode back into the first Prefetch Path?

i.e: prefetch.Add(PageTypeNode)?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 13-Jun-2006 00:12:00   

No, the Add() already added it simple_smile

Frans Bouma | Lead developer LLBLGen Pro