Prefetch Path & Predicate expression issue

Posts   
 
    
Elias
User
Posts: 5
Joined: 07-Apr-2006
# Posted on: 07-Apr-2006 10:52:37   

I have 3 tables like the following

TableA AId [PK] AField1 AField2 etc

TableB AId,DId,CId [PK] (where AId the PK of TableA and CId the PK of TableC so there are 2 foreign key relationships) BField1 BField2 etc

TableC CId [PK] CField1 CField2 etc

I want to fetch a collection of TableAEntity and prefetch TableB and TableCViaTableB

So I have the following code


IPrefetchPath2 path = new PrefetchPath2((int)EntityType.TableAEntity);
path.Add(TableAEntity.PrefetchPathTableB, 0, filter1,null,sorter1);
path.Add(TableAEntity.PrefetchPathTableCViaTableB, 0, filter2,null,sorter2);

How may I use filter2 in order to prefetch TableC Entities filtered by TableB fields (ex bring all TableC Entities where TableB.BField1 = true)?

Filter1 is a simple IPredicateExpression for a TableBFieldIndex.BField1 but Filter2 has to use a TableBFieldIndex.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Apr-2006 15:45:07   

Try to prefetch Table C as a subPath of the Prefetch of Table B

IPrefetchPath2 path = new PrefetchPath2((int)EntityType.TableAEntity);
path.Add(TableAEntity.PrefetchPathTableB, 0, filter1,null,sorter1).SubPath.Add(TableBEntity.PrefetchPathTableC, 0, filter2,null,sorter2);
Elias
User
Posts: 5
Joined: 07-Apr-2006
# Posted on: 08-Apr-2006 10:00:12   

Thank you for the prompt reply!

Not exactly what I was looking for since in this scenario filter1 works in addtion with filter2 and eliminates some entities from the second prefetch.

Trying to find a solution, I removed filter1, did the subpath.add and rewritten code elsewere (everything ok) but I am stuck with the question "is it possible to filter a EntityViaOtherEntity prefetch?" simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 08-Apr-2006 11:42:51   

I have to say I have a hard time grasping your initial post with the cryptic table names and 'filter1' and 'filter2' which are undeclared... Could you next time please use normal names for entities etc? That would be great simple_smile

Ok, on to your problem simple_smile Yes it is possible to filter a subpath node based on another entity. Specify a relationcollection and a filter on that related entity.

Frans Bouma | Lead developer LLBLGen Pro
Elias
User
Posts: 5
Joined: 07-Apr-2006
# Posted on: 08-Apr-2006 12:07:38   

Otis wrote:

I have to say I have a hard time grasping your initial post with the cryptic table names and 'filter1' and 'filter2' which are undeclared... Could you next time please use normal names for entities etc? That would be great simple_smile

Oh, I was trying to be ...generic wink

Thanx for the reply (and next time I will do RTFM first... found it in How To section...)

Live long and prosper simple_smile