This example uses PredicateBuilder by Albahari & Albahari - http://www.albahari.com/nutshell/predicatebuilder.aspxIf you need to return rows based on values of child items for the row, then the following example might come in useful:
predicate = predicate.And(p =>
p.OrderBasketItems.Where(obi => obi.CustomerId > 0).Count() > 0);This will generate a sub-query such as:
SELECT [t0].[ColumnX], [t0].[ColumnA]
FROM [dbo].[Order] AS [t0]
WHERE ([t0].[OrderStatusID] = 4) AND (((
SELECT COUNT(*)
FROM [dbo].[OrderItems] AS [t1]
WHERE ([t1].[CustomerId] > 0) AND ([t1].[OrderId] = [t0].[OrderID])
)) > 0)