public ActionResult Day()
{
var q = from o in _db.Orders
group o by o.OrderState
into g
select new {g.Key, Count = g.Sum(o => o.Id)};
return View(q);
}
以是有控制器中的代码,视图层:
@foreach (var item in Model) { <td>@item.Key</td> }
异常:object”未包含“Key”的定义,但是直接显示@item的话会显示{Key=ABC,Count=12}.求解
凤凰求蛊