NHibernate: Select entire entity plus aggregate columns

Posted by cbp on Stack Overflow See other posts from Stack Overflow or by cbp
Published on 2010-03-19T01:28:16Z Indexed on 2010/03/19 1:31 UTC
Read the original article Hit count: 313

Filed under:

I want to return an entire entity, along with some aggregate columns. In SQL I would use an inner select, something like this:

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

Is this possible with CreateCriteria?

© Stack Overflow or respective owner

Related posts about nhibernate