Hello everybody,
Let's start by the cats and kitten example. How do I get a list of
cats ordered by number of their kitten? I want all cats including
these that have no kitten.
To avoid any confusion this would be the layout of SQL query that
would give me what I want
SELECT c.*
FROM Cats c
left join Kitten k
on c.ID = k.CatID
WHERE (some_condition)
GROUP BY all_cat_fields
order by count(k.CatID) desc
Does anybody know of a way to do this using Criteria API? I have tried
many things so far and was unsuccesfull, so I must be missing
something.
A part of my code goes something like this:
DetachedCriteria kittenCriteria = null;
kittenCriteria = catcriteria.CreateCriteria("Kitten");
ProjectionList projList = Projections.ProjectionList();
projList.Add(Projections.GroupProperty("ID"), "zz"); //can't see this
zz in Profiler
projList.Add(Projections.GroupProperty("Name"));
//add other fields here
catcriteria.SetProjection(projList);
kittenCriteria.AddOrder(new Order(Projections.Count("CatID"),
true)); //this fails
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---