Well, I suppose in many instances one could "rewrite" this sort of query to use Sub Queries. But, it seems to me that a basic HAVING clause should be supported natively in the Dynamic Query API (or via some sort of "workaround" that the API enables). I still do not see a way to do the comparison in a WHERE clause referencing an aggregate count from the inner/sub query.
I still do not see a way to accomplish the SQL below using the Dynamic Query API:
Code:
SELECT c2.[CustomerID] AS 'CustomerID',
c2.[CompanyName] AS 'CompanyName',
c2.[ContactName] AS 'ContactName',
c2.[ContactTitle] AS 'ContactTitle',
c2.[Address] AS 'Address',
c2.[City] AS 'City',
c2.[Region] AS 'Region',
c2.[PostalCode] AS 'PostalCode',
c2.[Country] AS 'Country',
c2.[Phone] AS 'Phone'
FROM (SELECT c.[CustomerID],
COUNT(o.[OrderID]) AS 'OrdCnt'
FROM [Customers] c
INNER JOIN [Orders] o ON o.[CustomerID] = c.[CustomerID]
GROUP BY c.[CustomerID]
) sub
INNER JOIN Customers c2 ON sub.CustomerID = c2.CustomerID
WHERE sub.OrdCnt = <parm value>
I wonder if adding the "< arbitrary sql goes here >" functionality mentioned in the post below and on the Roadmap will be done in a way as to enable us to add a HAVING?
http://community.entityspaces.net/forums/thread/6899.aspx