gpt4 book ai didi

c# - nhibernate queryOver 投影语法

转载 作者:太空狗 更新时间:2023-10-29 20:11:44 24 4
gpt4 key购买 nike

我正在尝试 NH 3.0 Cookbook 中的一些代码,想知道为什么我无法编译下面的代码。我认为应该使这项工作起作用的 QueryProjectionBuilder 在“NHibernate.Criterion.Lambda”中,但它的 using 指令没有帮助。

问题出在 SelectGroup 和 SelectAvg 部分。假设书中的语法是正确的,任何人都可以看到这里缺少的引用吗?

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

关于c# - nhibernate queryOver 投影语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4481907/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com