[英]nhibernate queryOver projection syntax
I am trying some code out from a NH 3.0 Cookbook, and wondering why I can't get the code below to compile. 我正在尝试从NH 3.0 Cookbook中获取一些代码,并想知道为什么我无法获得下面的代码来编译。 I think the QueryProjectionBuilder that should make this work is in "NHibernate.Criterion.Lambda" but the using directive for it doesn't help.
我认为应该使这个工作的QueryProjectionBuilder在“NHibernate.Criterion.Lambda”中,但它的using指令没有帮助。
The problems are the SelectGroup and SelectAvg parts. 问题是SelectGroup和SelectAvg部分。 Assuming the syntax from the book is correct, can anyone see a missing reference 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]
});
}
}
}
您必须使用.SelectList
而不是.Select
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.