gpt4 book ai didi

c# - LINQ to Entities 无法识别方法 'System.Linq.IQueryable

转载 作者:太空狗 更新时间:2023-10-29 20:02:05 26 4
gpt4 key购买 nike

<分区>

当我尝试在子选择中调用我的存储库时,出现此错误。

 IGrpTextRepository rep = new GrpTextRepository();

var query = new DetailViewModel
{
ViewDet = (from gh in _db.Grp
select new MultiDetailViewModel
{
Header = gh,
Txts = rep.FindAllLangTxtById(gh.GrpID)

}).ToList(),
Lang = _db.Language.ToList(),

};

我的界面是

 public interface IGrpTextRepository
{
IQueryable<GrpText> FindAllLangTxtById(int GrpID);
}

public class GrpTextRepository : IGrpTextRepository
{
DBEntities db = new DBEntities();

public IQueryable<GrpText> FindAllLangTxtById(int GrpID)
{
return (from lang in db.Language
join gtxts in db.GrpText on lang.LangID equals gtxts.LangID into jointxt
from fintxt in jointxt.DefaultIfEmpty()
where fintxt.GrpID == GrpID
select fintxt);
}


}

这是完整的错误信息
System.NotSupportedException:LINQ to Entities 无法识别“System.Linq.IQueryable`1[aaa.Models.GrpText] FindAllLangTxtById(Int32)”方法,并且无法将此方法转换为存储表达式。

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