using ContosoUniversity.Models.SchoolViewModels; using ContosoUniversity.Data; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using ContosoUniversity.Models; namespace ContosoUniversity.Pages { public class AboutModel : PageModel { private readonly SchoolContext _context; public AboutModel(SchoolContext context) { _context = context; } public IList Students { get; set; } public async Task OnGetAsync() { IQueryable data = from student in _context.Students group student by student.EnrollmentDate into dateGroup select new EnrollmentDateGroup() { EnrollmentDate = dateGroup.Key, StudentCount = dateGroup.Count() }; Students = await data.AsNoTracking().ToListAsync(); } } }