tags:

views:

139

answers:

0

Hi everyone,

I'm struggling to find a simple example of using ICriteria (or the new QueryOver API) in nHibernate to write a query like this:

SELECT TOP (10) [t0].*
FROM [dbo].[ContentView] AS [t0]
INNER JOIN [dbo].[ContentTag] AS [t1] ON [t0].[UniqueID] = [t1].[ContentID]
WHERE [t0].[TypeName]='Book' AND [t1].[Name] IN ('aspnet', 'sqlserver'))
GROUP BY [t0].* -- simplified for brevity
HAVING COUNT([t1].UniqueID) > 0
ORDER BY COUNT([t1].UniqueID) DESC, [t0].[PublishedDate] DESC

How should I be doing this to get the HAVING clause working correctly? I'm trying with various projections and subquery conditions but that doesn't get me anywhere near the query above.

Any pointers or just a link to a similar example would be much appreciated.