Having a problem retrieving a list of items from the database. This is what I am attempting.
List<SubjectAreaGroup> subjectAreas = examInstance.CurrentQuestionGroup.QuestionTypeGroups.Select(q => q.SubjectAreaGroups).toList();
But when I do this, it gives me an error that I can’t convert a SubjectAreaGroup List to a… SubjectAreaGroup List. If they are the same thing then why can’t I convert them?
I assume that the issue is due to the
q.SubjectAreaGroupsproperty giving aList<SubjectAreaGroup>for each QuestionTypeGroup. Thus, yourSelectstatement is giving you a two-level sequence:IEnumerable<List<SubjectAreaGroup>>.To resolve this, you simply need to flatten your resulting sequences into one sequence using the
SelectManyoperator: