PagedList error: The method 'OrderBy' must be called before the method 'Skip'

前端 未结 1 952
心在旅途
心在旅途 2021-01-01 17:55

Here\'s the full error message: The method \'Skip\' is only supported for sorted input in LINQ to Entities. The method \'OrderBy\' must be called before the method \'Skip\'

相关标签:
1条回答
  • 2021-01-01 18:33

    You need to add an .OrderBy() in the expression:

    return View(db.PurchaseOrders.OrderBy(i => i.SomeProperty).ToPagedList(page ?? 1, 3));
    

    The .ToPageList() method uses .Skip() and .Take() so it must be passed an ordered collection first.

    0 讨论(0)
提交回复
热议问题