When I try to call my repository in a Sub Select, I got this error.
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(),
};
My Interface is
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);
}
}
Here is the full Error Message
System.NotSupportedException: LINQ to Entities does not recognize the method 'System.Linq.IQueryable`1[aaa.Models.GrpText] FindAllLangTxtById(Int32)' method, and this method cannot be translated into a store expression.