tags:

views:

30

answers:

0

I want to find out the amount of people that have read x number of books.

The setup is that I have a "Person" and a "ReadBooks" class.

What I tried to do is:

var innerProjection = Projections.ProjectionList()
                    .Add(Projections.GroupProperty("Person"), "Persons")
                    .Add(Projections.Count("Person"), "Count");

              var criteria = Session.CreateCriteria(typeof(ReadBooks))
                    .SetProjection(Projections.ProjectionList()
                                         .Add(Projections.GroupProperty(innerProjection[1]), "Persons")
                                         .Add(Projections.Count(innerProjection[0]), "Count"))
                    .List();

What I was hoping for was a list like the one below. The first row meaning that 1 person has read 10 books and the next row that 2 persons have read 8 books and so on.

NumberOfPersons, ReadBookCount

1, 10

2, 8

3, 5

10, 1

All I'm getting at the moment is complaints that it can not execute the query.