Prefetchpaths not working as I expected

Posts   
 
    
Karim
User
Posts: 14
Joined: 17-Dec-2007
# Posted on: 22-Jan-2008 12:21:52   

Hi I am trying to read the properties of a School entity as follows:

StageCollection sgc = new StageCollection(); PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.StageEntity); prefetchPath.Add(StageEntity.PrefetchPathBezoek); ** prefetchPath.Add(StageEntity.PrefetchPathLocatie).SubPath.Add(LocatieEntity.PrefetchPathSchool);** prefetchPath.Add(StageEntity.PrefetchPathStudentCollectionViaStudentStage); PredicateExpression filterGroep = new PredicateExpression(); filterGroep.Add(StageFields.Groep == groep); sgc.GetMulti(filterGroep, prefetchPath);

        foreach (StageEntity st in sgc)
        {
            st.Locatie.School.Naam; <-- the 'Naam' property isn't visible in intellisense, why not?
        }

Stage has an ID that references Locatie and Locatie has an ID that references School.

Thanks,Karim

Karim
User
Posts: 14
Joined: 17-Dec-2007
# Posted on: 22-Jan-2008 15:27:29   

Another question:

Can i add a filter on a a collection returned by this path: prefetchPath.Add(StageEntity.PrefetchPathStudentCollectionViaStudentStage);

Kind regards,Karim

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 22-Jan-2008 22:31:35   

Can i add a filter on a a collection returned by this path: prefetchPath.Add(StageEntity.PrefetchPathStudentCollectionViaStudentStage);

see this: Generated code - Using the EntityView2 class, Adapter

Karim
User
Posts: 14
Joined: 17-Dec-2007
# Posted on: 22-Jan-2008 23:51:48   

goose wrote:

Can i add a filter on a a collection returned by this path: prefetchPath.Add(StageEntity.PrefetchPathStudentCollectionViaStudentStage);

see this: Generated code - Using the EntityView2 class, Adapter

I understand. But what you suggest is to make a view and filter that view. What i want is pass in a filter so that only the objects i want to, are fetched. Is there any way to pass in a filter to this collection and that the getmulti understands that that filter has to be added?

What i understand from prefetchpaths is that it actually is a nested select statement. So how about giving that nested select statement a where clause. simple_smile

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 23-Jan-2008 09:35:03   

st.Locatie.School.Naam; <-- the 'Naam' property isn't visible in intellisense, why not?

Does it compile with no errors? otherwise I'd say check the relation and whether the school is an entity or a collection. Also maybe a re-build can do the trick here. Or maybe a Browsable = false attribute has been put there.

Can i add a filter on a a collection returned by this path: prefetchPath.Add(StageEntity.PrefetchPathStudentCollectionViaStudentStage);

Yes you can. Check the LLBLGen Pro reference manual for possible overloads of the PrefetchPath.Add() method. There you can find overloads that accepts PredicateExpression for filtering.

Karim
User
Posts: 14
Joined: 17-Dec-2007
# Posted on: 23-Jan-2008 14:08:21   

Walaa wrote:

st.Locatie.School.Naam; <-- the 'Naam' property isn't visible in intellisense, why not?

Does it compile with no errors? otherwise I'd say check the relation and whether the school is an entity or a collection. Also maybe a re-build can do the trick here. Or maybe a Browsable = false attribute has been put there.

Can i add a filter on a a collection returned by this path: prefetchPath.Add(StageEntity.PrefetchPathStudentCollectionViaStudentStage);

Yes you can. Check the LLBLGen Pro reference manual for possible overloads of the PrefetchPath.Add() method. There you can find overloads that accepts PredicateExpression for filtering.

Ok, i admit: i should have figured that out myself. simple_smile Thanks!