locked
How to union two IQueryables variables? RRS feed

  • Question

  • Hi,

    I'm trying to do this:

    // this works var modelBase = db.SerialKeyResourceProduct. Include(c => c.Product.ProductDescriptions). Include(c => c.SerialKeyResource).Include(d => d.SerialKeyResource.SerialKeyStatus); var modelPagedList = await modelBase.ToPagedListAsync(pageNumber, pageSize); // this not work /* I get follow error: System.NotSupportedException: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.*/ var modelBase = db.SerialKeyResourceProduct. Include(c => c.Product.ProductDescriptions). Include(c => c.SerialKeyResource); modelBase.Include(d => d.SerialKeyResource.SerialKeyStatus);

    var modelPagedList = await modelBase.ToPagedListAsync(pageNumber, pageSize);



    • Edited by Fabio Guaraldo Thursday, September 6, 2018 8:03 PM Forgot code
    Thursday, September 6, 2018 7:40 PM

All replies

  • Hi,

    Because the code is not completed, I could not reproduce the issue on my side. Based on the error message, it seems that have it is OrderBy, please modify your ToPagedListAsync code and add orderby method before skip method, like this:

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

    If the issue still exists, could you please share a simple complete sample via OneDrive. 

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 7, 2018 1:50 AM