I'm new to C# and I am trying to figure out how to Order the candidate list on the candidates index page by LastName in the Candidates controlle, here is the code:
// GET: Candidates
public async Task<IActionResult> Index()
{
var applicationDbContext = _context.Candidate.Include(c => c.Job);
return View(await applicationDbContext.ToListAsync());
}
CodePudding user response:
Try:
var applicationDbContext = _context.Candidate.Include(c => c.Job).OrderBy(l => l.LastName);