Get all customers with at least one order?

Posts   
 
    
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 11-Dec-2004 23:11:32   

Am I correct in assuming that I would need to use an Expression if I wanted to get all Customer entities with at least one Order entity?

And if so, how might I do that? I don't quite understand Expressions...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 12-Dec-2004 11:49:30   

You don't need an expression. Expressions are like: WHERE ShippingDate > (OrderDate + 3) (OrderDate + 3) is an expression here).

If you want customers which have 1 order at least, you simply specify a relation collection and the Customer - Order relation and that will result in an INNER JOIN, which will filter out customers without an order simple_smile You can also use a FieldCompareSetPredicate which compares customer.CustomerID with teh customerid's in the order table (Customer.CustomerID IN (SELECT CustomerID FROM Orders)) . The FieldCompareSetPredicate is likely to be a bit faster.

Frans Bouma | Lead developer LLBLGen Pro