Relations

Posts   
 
    
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 07-Apr-2010 21:16:10   

I have to join two tables in LLBL but in database there is no relationship exists between these two tables (otherwise I could have simply used RelationCollection). Any idea how can I do this join between these two tables in LLBL?

imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 07-Apr-2010 23:02:07   

Just to be clear none of these two fields are primary keys.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Apr-2010 05:18:42   

Yes, you can create an instance of EntityRelation, and pass the fields and joinHint to the constructor.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39872
Joined: 17-Aug-2003
# Posted on: 10-Apr-2010 10:18:39   

In v2.6 we made this easier with the 'DynamicRelation' class, which is in the generated code

Frans Bouma | Lead developer LLBLGen Pro
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 13-Apr-2010 17:06:57   

ok, so when I add this relation using DynamicRelation, I get following error

Relation at index 2 doesn't contain an entity already added to the FROM clause. Bad alias?

Any idea what I may be doing wrong?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39872
Joined: 17-Aug-2003
# Posted on: 13-Apr-2010 18:17:32   

imakimak wrote:

ok, so when I add this relation using DynamicRelation, I get following error

Relation at index 2 doesn't contain an entity already added to the FROM clause. Bad alias?

Any idea what I may be doing wrong?

A code snippet would help out alot wink

Frans Bouma | Lead developer LLBLGen Pro
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 13-Apr-2010 19:00:44   

Actually I figured it out. It was my bad with the aliasing thing in the DynamicRelation constructor. Thanks for your help anyways