Join in sub-query

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 26-Oct-2008 22:13:51   

Hi,

How do I do a join in a sub-query? The FieldCompareSetPredicate only seems to take a predicate so where would I specify a join?

Is there anything in the manual about writing sub-queries? I can't even get the FieldCompareSetPredicate constructor to compile because for its first parameter it wants an IEntityField instead of an IEntityField2!

And what are the 'field' and 'setField' parameters for anyway?

I understand that you can do a sub-query with a join but then I have to do a distinct which I don't feel like doing. wink

Cheers, Ian.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Oct-2008 02:58:19   

Ian wrote:

How do I do a join in a sub-query? The FieldCompareSetPredicate only seems to take a predicate so where would I specify a join?

Derived tables and Dynamic relations is designed for that.

Ian wrote:

Is there anything in the manual about writing sub-queries? I can't even get the FieldCompareSetPredicate constructor to compile because for its first parameter it wants an IEntityField instead of an IEntityField2!

You should use this overload (ref...):

public FieldCompareSetPredicate(
     IEntityFieldCore field, 
     IFieldPersistenceInfo persistenceInfoField, 
     IEntityFieldCore setField, 
     IFieldPersistenceInfo persistenceInfoSetField, 
     SetOperator operatorToUse, 
     IPredicate filter)

For example:

FieldCompareSetPredicate subQueryFilter = new FieldCompareSetPredicate(
    OrdersFields.OrderId, null, OrderDetailsFields.OrderId, null,
     SetOperator.In, (OrderDetailsFields.UnitPrice > 1));

Ian wrote:

And what are the 'field' and 'setField' parameters for anyway?

See above "ref..." link.

David Elizondo | LLBLGen Support Team