本文介绍了Linq分组.include(“表”)在表上返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要加载表AssessmentQuestionsReference,以便我可以绑定到我的WPF应用程序中。
$ b $ <您的 .Include(AssessmentQuestions)将拉入 a.AssessmentQuestions ,但不是 a.AssessmentQuestions.AssessmentQuestionGroups 。I have a linq query that is grouping by answers by QuestionGroup.
I need to have the table AssessmentQuestionsReference load so that i can bind to it in my WPF app.
var groupedAnswers = from a in App.ents.AssessmentAnswers.Include("AssessmentQuestions") where a.Organisations.OrganisationID == App.selectedOrganisation.OrganisationID group a by a.AssessmentQuestions.AssessmentQuestionGroups.QuestionGroup into g select new { Group = g.Key, Answer = g };When i drill down into g, AssessmentQuestions is "null". I am not sure why as i thought it should have loaded it even without the include as i am going through that table to get the question groups.
Any ideas?
解决方案Have you tried including AssessmentQuestions.AssessmentQuestionGroups?
Your .Include("AssessmentQuestions") will pull in a.AssessmentQuestions, but not a.AssessmentQuestions.AssessmentQuestionGroups.
这篇关于Linq分组.include(“表”)在表上返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!