How to join to same table twice

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 23-Sep-2017 18:49:03   
bucket.Relations.Add(GuestEntity.Relations.AccountEntityUsingGuestAccountId, "guestAccount");
bucket.Relations.Add(GuestEntity.Relations.AccountEntityUsingAccountId, "mainAccount");
bucket.Relations.Add(AccountEntity.Relations.VwEventAccountEntityUsingAccountId);

The generated query doesn't include the second join so it tries to join to VwEventAccount using guestAccount's AccountId.

How do I make it use mainAccount's accountId to do the third join?

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 23-Sep-2017 19:23:04   

This worked...

bucket.Relations.Add(GuestEntity.Relations.AccountEntityUsingAccountId, "mainAccount");

var rel = AccountEntity.Relations.VwEventAccountEntityUsingAccountId;
rel.SetAliases("mainAccount", string.Empty);

bucket.Relations.Add(vwEventAccountEntityUsingAccountId);