ToRowCountQuery seems to ignore groupings

↘锁芯ラ 提交于 2019-11-28 02:04:04
Firo

Edited:

ToRowCountQuery removes all Projections even the groupings. If you run the query yourself you will see that count(*) in a query with group by will return the count of each group not the number of groups. you have to COUNT DISTINCT all group-columns to get the number of groups.

You need someting like SELECT count(*) FROM (query) which is not directly possible. i can only think of a fragile solution where you generate the sql like shown here and then

string sql = GenerateSQL(query.UnderlyingCriteria);
rowcount = session.CreateSQLQuery(string.Format("SELECT Count(*) FROM ({0})", sql)).SetParameter("???", KlantId).FutureValue<int>();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!