Alan Alan - 4 months ago 24
ASP.NET (C#) Question

How to order by date from new to oldest?

I'm having trouble sorting a list of dates from newest to oldest. Any ideas?

My code is as follow:

public async Task<IActionResult> Prices()
var allResults = from result in _context.Reviews
orderby result.Date descending
select result;

return View(await allResults.ToListAsync());


I receive the following error message:

CS1061 'DbSet' does not contain a definition for
'OrderByDescending' and no extension method 'OrderByDescending'
accepting a first argument of type 'DbSet' could be found
(are you missing a using directive or an assembly reference?)


Add using System.Linq;

That will solve your problem.