NHibernate:选择整个实体加上聚合列

时间:2010-03-19 01:28:16

标签: nhibernate

我想返回整个实体以及一些聚合列。在SQL中我会使用内部选择,如下所示:

SELECT TOP 10 f.*, inner_query.[average xxx]
FROM (
      SELECT f.Id, AVG(fb.xxx) AS [average xxx]
      FROM foobar fb
      INNER JOIN foo f ON f.FoobarId = fb.Id
     ) AS inner_query
INNER JOIN foo f ON f.Id = inner_query.Id

CreateCriteria可以实现吗?

1 个答案:

答案 0 :(得分:1)

您可以向实体添加公式属性:see #5 on this list