我将一些数据组合在一起,以便可以在首页(ASPX)上显示它。
我有以下代码:-
IEnumerable<ReportQuestion> questionSubjectGrps =
questionsBll.GetReportQuestions()
.Where(x => x.VersionId == iLatestVersion);
reportQuestionsList =
questionSubjectGrps.GroupBy(q => q.SubjectId,
(qid, qs) => qs.GroupBy(q => q.ParentId));
foreach (ReportQuestion reportQuestion in reportQuestionsList)
{
ReportQuestionsGuiDisplay reportQuestionsGuiDisplay =
new ReportQuestionsGuiDisplay();
reportQuestionsGuiDisplay.ParentQuestionTitle =
questionsBll.GetQuestionParents()
.FirstOrDefault(
x => x.QuestionParentId == reportQuestion.ParentId)
.QuestionParentTitle;
reportQuestionsGuiDisplay.ReportId = reportQuestion.ReportId;
reportQuestionsGuiDisplayList.Add(reportQuestionsGuiDisplay);
}
在前端(ASPX),我有以下内容:
<% foreach (ReportQuestionsGuiDisplay report in reportQuestionsGuiDisplayList)
{%>
<div class="hrLightBlue"></div>
<div class="RPTContentTitle2">
<%= report.SubjectTitle %>
</div>
<div class="hrLightBlue"></div>
<%} %>
但是我收到以下错误:
无法将“ ”类型的对象转换为“
System.Linq.GroupedEnumerable``3[SCPerformance.Shared.Models.ReportQuestion,System.Nullable``1[System.Int32],SCPerformance.Shared.Models.ReportQuestion]
”类型SCPerformance.Shared.Models.ReportQuestion
。