代码之家  ›  专栏  ›  技术社区  ›  Newbie

如何使用NH生成“select count(*)as y from(select distinct x,y from tableName)as t”?

  •  3
  • Newbie  · 技术社区  · 15 年前

    关于如何使用Criteria API用Nhibernate生成后续查询有什么想法吗?

    select count(*)as z from (select distinct x, y from tableName) as t
    

    select count(distinct (x , y)) as z FROM tableName
    

    其他返回相同结果的查询。

    1 回复  |  直到 15 年前
        1
  •  3
  •   Sly    15 年前

    您可以尝试在ICriteria API和Projection的帮助下生成这样的查询。你需要的是 Projections.RowCount() Projections.Distinct() , Projections.Property()