The method 'Skip' is only supported for sorted input in LINQ to Entities

前端 未结 4 755
执笔经年
执笔经年 2021-02-12 10:07

What could be causing this problem?

public ActionResult Index(int page = 0)
{
    const int pageSize = 3;
    var areas = repo.FindAllAreas();
    var paginatedA         


        
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-12 10:31

    Seems like the error is exactly what it is says. "Skip is only allowed on Sorted inputs". Searching for this error, I've found this.

    It should be fixed if you include an OrderBy before Skip:

    source.orderBy(???).Skip(PageIndex * PageSize).Take(PageSize)); 
    

    Which might be a problem since you are passing a generic object T. You might need to expand your class to receive another parameter to indicate the order by element.

提交回复
热议问题