gpt4 book ai didi

c# - nhibernate 3 不支持指定的方法

转载 作者:行者123 更新时间:2023-11-30 16:31:53 25 4
gpt4 key购买 nike

我最近从 nhibernate 2 迁移到 3,我遇到的问题是,在我现在遇到问题之前遇到的大多数查询中。我看到这个错误 Specified method is not supported尽管它们在 hibernate 2 中都运行良好。这些查询中的一个是这样的

 public JsonResult AllEducationDegree(string search)
{
var data = Repository<EducationDegree>
.FindBySpecification(new EducationDegreeSpecification().Search(search))
.Take(10)
.Select(p => new NameValue(p.Title, (int)p.Id))
.ToList();
// .AsDropdown(" ");
return Json(data, JsonRequestBehavior.AllowGet);
}

public class EducationDegreeSpecification : FluentSpecification<EducationDegree>
{
public EducationDegreeSpecification Search(string EducationDegreeSearch)
{
if (!String.IsNullOrEmpty(EducationDegreeSearch))
{
string[] searchs = EducationDegreeSearch.Split(' ');
foreach (string search in searchs)
{
if (!String.IsNullOrEmpty(search))
{
AddExpression(p => p.Title.Contains(search));
}
}
}
return this;
}

}

最佳答案

您需要在 Take 之前选择。它应该有效。

   var data = Repository<EducationDegree>
.FindBySpecification(new EducationDegreeSpecification().Search(search))
.Select(p => new NameValue(p.Title, (int)p.Id))
.Take(10)
.ToList();
// .AsDropdown(" ");
return Json(data, JsonRequestBehavior.AllowGet);

关于c# - nhibernate 3 不支持指定的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4554315/

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