public class IndexModel : PageModel
{
private readonly ContosoUniversity.Models.SchoolContext _context;
public IndexModel(ContosoUniversity.Models.SchoolContext context)
{
_context = context;
}
public List<Student> Student { get;set; }
public async Task OnGetAsync()
{
Student = await _context.Student.OrderByDescending(x=>x.EnrollmentDate).Where (x=>x.ID.Equals("11")).ToListAsync();
}
}
context 就是一个库._context是全局的库.
表达式:条件筛选.