Filter by JOIN?

Posts   
 
    
M6rk
User
Posts: 37
Joined: 29-Sep-2004
# Posted on: 12-Apr-2007 20:23:09   

Given a pair of tables:

Tables T1 ( id int g int SomeAttributeA int Primary Key (id,g) ) T2 ( id int g int SomeAttributeB int Primary Key (id, g) )

Using an Entity collection based on T1, how can I filter the T1 entity collection based on value of T2.SomeAttibuteB

By doing this:

SELECT T1.SomeAttributeA FROM T1 JOIN T2 ON T1.id=T2.id AND T1.g=T2.g WHERE T2.SomeAttributeB = 10

(See attached for script to create and execute sample)

Attachments
Filename File size Added on Approval
JoinTrials.sql 661 13-Apr-2007 13:55.27 Approved
JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 13-Apr-2007 06:59:22   

Please look at the "Multi-entity filters" section in "Generated code - Advanced filter usage" in the dcumentation.

Please let us know if that doesn't answer your question.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Apr-2007 11:42:13   

(See attached for script to create and execute sample)

BTW, there is no attachment there.

M6rk
User
Posts: 37
Joined: 29-Sep-2004
# Posted on: 13-Apr-2007 16:08:05   

JimHugh wrote:

Please look at the "Multi-entity filters" section in "Generated code - Advanced filter usage" in the dcumentation.

Please let us know if that doesn't answer your question.

Thanks for the pointer. This section did lead to a solution:

I had explored that a little but gave up. The generated code for the entities did not have any defined relationships, and the GetSubTypeRelation was returning null. Which makes sense because there is no FK relationship defined between them in the database. What I needed to do was use the LLBLGenPro designer and define specific relationships between these entities.

The rest of the solution was as stated in the help file section you kindly pointed out.

Thanks for your help!