如何在cshtml中显示键和计数数据
这是类:
public class ViewModelData
{
public int Key { get; set; }
public int Count { get; set; }
}
这是控制器:
public ActionResult Trigger()
{
var result = repository.Paths.GroupBy(x => x.SmokeCar)
.Select(x => new ViewModelData
{
Key = x.Key,
Count = x.Count()
}).ToList();
return View(result);
}
这是cshtml
@model IEnumerable CessationPath.Domain.Entities.ViewModelData
<div>
<span>Count:</span>
</div>