tags:

views:

126

answers:

1

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?

+2  A: 

Have you tried including "AssessmentQuestions.AssessmentQuestionGroups"?

Your .Include("AssessmentQuestions") will pull in a.AssessmentQuestions, but not a.AssessmentQuestions.AssessmentQuestionGroups.

Darren
I have since changed my code significantly and approached this differently so i cant test if this works. But +1 for offering a solution. Thanks
Kohan
Thanks! So long as AssessmentQuestionGroups is not a primitive type, I think that was probably your problem.
Darren