Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Phil Dye 149 posts 325 karma points
    Mar 28, 2011 @ 17:59
    Phil Dye
    0

    Linq Extension methods on Examine SearchResults

    I'm having trouble using Skip() and Take() to acheive pagination on a set of Examine SearchResults, getting an error

    macroScripts\SearchResults.cshtml(46): error CS1973: 'System.Linq.IQueryable' has no applicable method named 'Skip' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

    Abbrieviated source;

     

    var pagesToList = ExamineManager.Instance.SearchProviderCollection["ContentSearcher"].Search(filter).Distinct().AsQueryable();
    
    // lots of pagination stuff trimmed
    
    @foreach (var item in pagesToList.Skip(currentPage * itemsPerPage).Take(itemsPerPage))   
    {
    <li>@item.Name</li>
    }

     

    Surely Skip() and Take() should be available? I've tried casting pagesToList to a DynamicNodeList, and no luck there either?

    Phil

     

  • Phil Dye 149 posts 325 karma points
    Mar 28, 2011 @ 18:28
    Phil Dye
    0

    Doh, I knew if I posted the solution would appear... The clue is in the error "Consider casting the dynamic arguments" - itemsPerPage was dynamic, so needed casting to an int.

    Phil

Please Sign in or register to post replies

Write your reply to:

Draft