using multiple relations and filters to the same table

Posts   
 
    
kuranyi
User
Posts: 4
Joined: 22-Oct-2007
# Posted on: 22-Oct-2007 22:02:29   

Hi,

I have a problem with relations and filters.

I have attached a picture to the message.

There are 3 tables. First one includes 2 FK fields. CityID and CountryID. tehre is a connection table. I wanna retrieve name values for these fields from 3.Table with a filter (languageID in 3. table)

I wish someone can help me.

Attachments
Filename File size Added on Approval
problem.JPG 14,343 22-Oct-2007 22:02.43 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Oct-2007 05:11:33   

Hi kuranyi,

Could you please provide more information? http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7720

As far as I understand you, you could do something like:

EntityCollection<Table1Entity> table1Coll = new EntityCollection<Table1Entity>(new Table1EntityFactory());

IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.Relations.Add(Table1Entity.Relations.Table2EntityUsingLocationID);
filter.Relations.Add(Table2Entity.Relations.Table3EntityUsingLingualID);

filter.PredicateExpression.Add(Table3Fields.SomeField == someValue);

You can also should include PrefetchPaths if you want to access later the objecst (table2 and table3) related to table1.

For more information read: LLBLGenPro Help - Using generated code (Adapter | Selfserficing) - Filtering and Sorting - Advance filter usage - Multi-entity filters.

David Elizondo | LLBLGen Support Team
kuranyi
User
Posts: 4
Joined: 22-Oct-2007
# Posted on: 23-Oct-2007 08:20:59   

hi again,

thanks for your reply, i think i could not explain my situation clearly.

Here it is:

this is your answer

IRelationPredicateBucket filter = new RelationPredicateBucket(); filter.Relations.Add(Table1Entity.Relations.Table2EntityUsingCityID); filter.Relations.Add(Table2Entity.Relations.Table3EntityUsingLingualID);

filter.PredicateExpression.Add(Table3Fields.SomeField == someValue);

and it gets only city name field from 3. table for me.

But i also want country name field from 3 table exactly using same relations.

IRelationPredicateBucket filter = new RelationPredicateBucket(); filter.Relations.Add(Table1Entity.Relations.Table2EntityUsingCountryID); filter.Relations.Add(Table2Entity.Relations.Table3EntityUsingLingualID);

filter.PredicateExpression.Add(Table3Fields.SomeField == someValue);

If you view attachmets you will understand my problem. You can think 3. record in first table.

Thanks again

kuranyi
User
Posts: 4
Joined: 22-Oct-2007
# Posted on: 23-Oct-2007 10:25:53   

Hi everyone,

I have solved my problem.

I just learned how to use alias for relations and filters.

Thaks a lot.