Inner join

Posts   
 
    
JedC#
User
Posts: 9
Joined: 21-Apr-2010
# Posted on: 23-Apr-2010 15:18:03   

How would one do this in llblgen

select col1,col2 From table1 T inner join table2 T2 on T.col3 = T2.col3 where T.col3 = 'whatever' and T2.col3 = 'whatever'

I am using RelationPredicateBucket bucket = new RelationPredicateBucket();

                //  relations 
                bucket.Relations.Add(AccountEntity.Relations.InvoiceEntityUsingAccountId);

                //  filters
                bucket.PredicateExpression.Add(AccountFields.AccountId == AccountId);
                bucket.PredicateExpression.AddWithAnd(InvoiceFields.InvoiceId == InvoiceId);

This filters for the account but not the invoice

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 23-Apr-2010 18:01:35   

In the SQL you posted, the second part of the WHERE clause would be unnecessary as you are filtering both sides of a column you are joining on (perhaps that's a typo?).

Assuming the predicate/relation code is more representative of what you are trying to do, the filtering looks correct to me. However it's not clear where you are using the filter and joins. It it part of dynamic list? As part of an entity or entity collection fetch? As a prefetch node in a graph fetch?

A little more context on how this code is being used results you are seeing (vs. expecting to see) would shed more light on the problem.

Phil