我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