I am trying to use some code from a Cookbook in NH 3.0 and wonder why I cannot get the code below to compile. I think the QueryProjectionBuilder that should do this work is in "NHibernate.Criterion.Lambda", but the directive on using this does not help.
Problems are the elements of SelectGroup and SelectAvg. Assuming the syntax from the book is correct, can anyone see the missing link here?
namespace Queries.Implementations { using System; using System.Collections.Generic; using System.Linq; using Eg.Core; using NHibernate; using NHibernate.Criterion; using NHibernate.Criterion.Lambda; public class QueryOverQueries : CookbookQueriesBase { public override IEnumerable<NameAndPrice> GetAvgDirectorPrice(ISession session) { return _session.QueryOver<Movie>() .Select(list => list .SelectGroup(m => m.Director) .SelectAvg(m => m.UnitPrice) ) .List<object[]>() .Select(props => new NameAndPrice { Name = (string) props[0], Price = (decimal) props[1] }); } } }
Berryl
source share