I am getting a MismatchedTreeNodeException throw with the simple query below using NHibernate 3.2.0.4000. I am assuming it is a bug and if so does anyone know of a work around?
var result = session.Query<File>()
.OrderBy(x => x.Author)
.GroupBy(file => file.Author)
.Select(author => new FileAuthor(author.Key, author.Count()))
.ToList();
I have played around with your example and query in this form works fine:
Apparently, when you group by entity, it is possible only to project its ID and aggregations. It seems that sorting needs to be done on the client.
Used mappings: