我在控制器中得到了这个
var tobi = (from a in db.Assessments
join u in db.Users on a.rated equals u.user_id
join tm in db.Team_Members on u.user_id equals tm.user_id
join t in db.Teams on tm.team_id equals t.team_id
where (tm.end_date == null || tm.end_date > DateTime.Today)
group new TobiViewModel
{
teamname = t.name,
assessed_due = a.assessed_due,
assessment_id = a.assessment_id,
rater = a.rater,
rated = a.rated
}
by new { t.name, a.rated }).ToList();
return View(tobi);
但是它在视图中不接受它?
传递到字典中的模型项是类型的 'System.Collections.Generic.List
1[System.Linq.IGrouping
2 [<> f__AnonymousType102[System.String,System.String],Kyubu.ViewModels.TobiViewModel]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1 [Kyubu.ViewModels.TobiViewModel]'。
我应该如何在视图中传递此信息。任何帮助,将不胜感激 视图中的类型是
@model IEnumerable<Kyubu.ViewModels.TobiViewModel>
答案 0 :(得分:6)
在视图中尝试以下内容:
@model IEnumerable<System.Linq.IGrouping<object, Kyubu.ViewModels.TobiViewModel>>