【发布时间】:2018-08-30 10:40:39
【问题描述】:
我在索引页面后面有以下代码:
public async Task OnGetAsync()
{
var tournamentStats = await _context.TournamentBatchItem
.Where(t => t.Location == "Outdoor" || t.Location == "Indoor")
.GroupBy(t => t.Location)
.Select(t => new { Name = $"{ t.Key } Tournaments", Value = t.Count() })
.ToListAsync();
tournamentStats.Add(new { Name = "Total Tournaments", Value = tournamentStats.Sum(t => t.Value) });
}
在这个代码后面我也有这个类的定义:
public class TournamentStat
{
public string Name { get; set; }
public int Value { get; set; }
}
public IList<TournamentStat> TournamentStats { get; set; }
如何将 tournamentStats / TournamentStats 引用到 Razor 页面?
【问题讨论】:
标签: c# asp.net-core razor-pages