colinramsay.co.uk

NHibernate Query Woes

21 May 2008

I'm banging my head trying to solve a particular type of querying problem. I think I can simplify it like this:

Categories have many Posts, Posts have many Comments

I'd like to search for Comments with a particular author, which is easy enough, but I'd like my result set to be made up of Blogs which contain Posts which contain Comments with author = 'ramsay'.

The problem I'm having is that if I have 50 Comments then it'll return 50 duplicate Blogs to contain those comments. Argh! I can add groupings (i.e. group by Blog), but that means it'll only pull back the things I group by and not the full Blog objects.