I got this error when I was using "LINQ to entities" to show every single product and implement paging in ASP.NET MVC.:
The method 'Skip' is only supported for sorted input in LINQ to Entities.
The method 'OrderBy' must be called before the method 'Skip'."
LINQ:
Model.Name = db.Products.Where(p => p.ProductSubcategoryID == id)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToList();
How can I fix it? What would happen if I put OrderBy
instead of Where
?