This HQL statement, when executed produces this the following result:
Code:
select t, count(s) from Submission s right join s.Topics as t GROUP BY t.Id
result[0]
[0] topic A
[1] 10
result[1]
[0] topic B
[1] 12
.
result[n]
[0] topic N
[1] 19
This DetachedCriteria API produces almost similar result but without loading the topic
Code:
ProjectionList PrjList = Projections.ProjectionList();
PrjList.Add(Projections.GroupProperty("Topics"), "t");
PrjList.Add(Projections.Count("Id"));
DetachedCriteria Filter = DetachedCriteria.For<Submission>();
Filter.CreateCriteria("Topics", "t", JoinType.RightOuterJoin);
Filter.SetProjection(PrjList);
result[0]
[0] null
[1] 10
result[1]
[0] null
[1] 12
.
result[n]
[0] null
[1] 19
For some reason Nhibernate refuses to create topic objects for the result set but it does for the HQL. How should I alter the DetachedCriteria to get the same result?