我LINQ查询包含路径表达式必须引用该类型上定义的导航属性。
model.Questions = db.Questions
.Where (x => x.CategoriesID == categoryId)
.Include (qc => qc.QuestionCounters.Where(x => x.MemberID == User.Identity.GetUserId()))
.Include (qf => qf.QuestionFavorites.Where(x => x.MemberId == User.Identity.GetUserId()))
.Include (qt => qt.QuestionTags)
.ToList();
产生错误
“包含路径表达式必须引用的类型所限定的导航属性 。使用虚线路径作为参考导航 属性,并使用选择运算符来收集导航 属性。
任何想法为什么会发生这种情况?
你不能使用包含来选择数据。已经有很多帖子了。 – Equalsk
@Equalsk有没有其他的选择?这一个怪胎我 – OrElse
重复 - 请参阅此https://stackoverflow.com/questions/15980665/ef-lambda-the-include-path-expression-must-refer-to-a-navigation-property和此https:/ /stackoverflow.com/questions/38676029/the-include-path-expression-must-refer-to-a-navigation-property-defined-on-the-t。 – 2017-08-03 14:21:53