Reputation: 713
I got this in the controller
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);
But then it doesn't accept it in the view?
The model item passed into the dictionary is of type '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]'.
how should i pass this in the view. Any help would be appreciated The type in the view is
@model IEnumerable<Kyubu.ViewModels.TobiViewModel>
Upvotes: 3
Views: 2443
Reputation: 3571
Try the following in the view:
@model IEnumerable<System.Linq.IGrouping<object, Kyubu.ViewModels.TobiViewModel>>
Upvotes: 6