gpt4 book ai didi

asp.net-mvc - 通过 group by 传递 linq 查询以查看 [errors out]

转载 作者:行者123 更新时间:2023-12-04 16:45:46 25 4
gpt4 key购买 nike

我在 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);

但是它不在 View 中接受它?

The model item passed into the dictionary is of type 'System.Collections.Generic.List1[System.Linq.IGrouping2[<>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]'.

我应该如何在 View 中传递它。任何帮助,将不胜感激 View 中的类型是

@model IEnumerable<Kyubu.ViewModels.TobiViewModel>

最佳答案

在 View 中尝试以下操作:

@model IEnumerable<System.Linq.IGrouping<object, Kyubu.ViewModels.TobiViewModel>>

关于asp.net-mvc - 通过 group by 传递 linq 查询以查看 [errors out],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13074786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com