NHibernate QueryOver Having子句

emp*_*ron 5 nhibernate queryover

我想用QueryOver编写这样的查询,以便结果SQL类似于以下内容:

Select Bar, count(*) from Foo group by Bar having count(*) > 1
Run Code Online (Sandbox Code Playgroud)

我该怎么做 ?

Vad*_*dim 7

我想你只会使用Where方法

Session.QueryOver<Foo>()
    .Select(Projections.GroupProperty(Projections.Property<Foo>(foo => foo.Bar)),
            Projections.Count<Foo>(f => f.Id))
    .Where(Restrictions.Gt(Projections.Count<Foo>(f => f.Id), 1));
Run Code Online (Sandbox Code Playgroud)