Copied to clipboard

Flag this post as spam?

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


  • Graham Carr 277 posts 389 karma points
    Apr 24, 2013 @ 11:30
    Graham Carr
    0

    Problem with .Skip functionality

    I am using the Auros categorisation package and I am having issues with some functionality that uses the .SKIP method. Namely, the following piece of code

    var pagesToList = NodeHelpers.GetNodesInCategory("Testimonial",Convert.ToInt32(Request["c"],0));var numberOfItems = pagesToList.Count();
    currentPage--;
    var numberOfPages = numberOfItems % itemsPerPage == 0 ? Math.Ceiling((decimal)(numberOfItems / itemsPerPage)) : Math.Ceiling((decimal)(numberOfItems / itemsPerPage))+1;
    var Pages = Enumerable.Range(1, (int)numberOfPages);

    @foreach(var item in pagesToList.Skip(currentPage*itemsPerPage).Take(itemsPerPage))
    {
    }


    Is giving me the following error message: error CS1973: 'umbraco.NodeFactory.Node[]' 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.

    I just can't work out how to cast the pagesToList variable so that the .Skip functionality will work, which is being used for paging purposes. Does anyone have any idea as to how I can accomplish this?

     

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Apr 24, 2013 @ 12:01
    David Brendel
    1

    Maybe i'm wrong but i think that it's not because of the pagesToList variable. It's because of the parameters you gave to the Skip() method.

    Both variables are of type dynamic. Try to use "int" instead. Maybe that helps.

  • Graham Carr 277 posts 389 karma points
    Apr 24, 2013 @ 12:07
    Graham Carr
    0

    Perfect, thank you very much, that was indeed the issue and changing from "var" to "int" solved the problem straight away. I will keep that in mind for the future!!

Please Sign in or register to post replies

Write your reply to:

Draft