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

前端 未结 4 1095
暖寄归人
暖寄归人 2021-02-12 10:18

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:34

    that is worked (use first IOrderedQueryable):

    http://msdn.microsoft.com/en-us/library/bb738702.aspx

     IOrderedQueryable products = context.Products
            .OrderBy(p => p.ListPrice);
    
    IQueryable allButFirst3Products = products.Skip(3);
    
    Console.WriteLine("All but first 3 products:");
    foreach (Product product in allButFirst3Products)
    {
        Console.WriteLine("Name: {0} \t ID: {1}",
            product.Name,
            product.ProductID);
    }
    

提交回复
热议问题