我得到了LINQ查询,它将问题及其可能的答案分组。我可以将问题作为group.key获取,但是答案列表将作为匿名列表出现,我需要将其指定为“AnswersList”
请参阅以下屏幕截图,我还指出我需要将4个列表分配给特定名称
var k1 = (from question in Context.Questions.Where(question => question.ConsultationId == ConsultationId && question.IsSubQuestion == false)
select new
{
question,
subQuestions = from subQuestion in Context.Questions
join questionHierarchy in Context.QuestionHierarchy on subQuestion.Id equals questionHierarchy.ChildQuestionId
where questionHierarchy.ParentQuestionId == question.Id
join questionAnswerOptionsJoin in Context.QuestionPreDefineAnswerOptionJoin on subQuestion.Id equals questionAnswerOptionsJoin.QuestionId
join preDefineAnswerOption in Context.PreDefineAnswerOptions on questionAnswerOptionsJoin.PreDefineAnswerOptionId equals preDefineAnswerOption.Id
group preDefineAnswerOption by subQuestion into g
select new
{
g,
//answersList ={} ??????????????
}
}).ToList();