where not in

Posts   
 
    
Noer
User
Posts: 33
Joined: 04-Jan-2007
# Posted on: 26-Jan-2007 15:50:36   

Hello

I have the folowing code:

OrderCollection result = new OrderCollection();
            IPredicateExpression filter = new PredicateExpression();
            filter.Add(OrderFields.CustomerID == customerID);
            filter.Add(new FieldCompareSetPredicate(OrderFields.OrderID, OrderInvoiceFields.NewInvoiceOrderID, SetOperator.In, null));
            result.GetMulti(filter);

which generates something like this:

select * from order where order.OrderID IN (select NewInvoiceOrderID from ......)

Instead of where order.OrderID IN I want it to be where order.OrderID NOT IN. How do I do that?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Jan-2007 15:56:41   

Use the extra paramtere overload of the function:

public FieldCompareSetPredicate( 
   IEntityField field,
   IEntityField setField,
   SetOperator operatorToUse,
   IPredicate filter,
   bool negate
)

The last parameter is bool negate.

I also guess you can try this code out:

filter.Add( ! new FieldCompareSetPredicate(OrderFields.OrderID, OrderInvoiceFields.NewInvoiceOrderID, SetOperator.In, null));

Note the '!'.

Noer
User
Posts: 33
Joined: 04-Jan-2007
# Posted on: 26-Jan-2007 16:10:11   

Thanks

They both works