Copied to clipboard

Flag this post as spam?

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


  • Richard Brookes 34 posts 57 karma points
    Dec 16, 2012 @ 10:28
    Richard Brookes
    0

    DynamicNodeList and Linq extensions

    When looping through a list of nodes using something like .Children or Descendants etc I can use Linq extensions such ad orderBy, Skip, Take etc.

    e.g. foreach(var item in Model,Children.OrderBy("Name").Skip(x).Take(y))

    However in one situation I am using a function that returns a DynamicNodeList as my source. When I try to use these methods on this list I receive the dollowing error when trying to save the file

    e.g. foreach(dynamic item in MyFunctionThatReturnsDynamicNodeList().OrderBy("Name").Skip(x).Take(y).ToList())

     

    The type arguments for method 'umbraco.MacroEngines.DynamicNodeList.OrderBy(string)' cannot be inferred from

    the usage. Try specifying the type arguments explicitly.

    Can anybody tell me why this could be?

     

  • Mike Chambers 636 posts 1253 karma points c-trib
    Dec 17, 2012 @ 10:28
    Mike Chambers
    0

    you might have some look with the ToArray() method and then revert to linq 

     

    eg

    DNL.ToArray().OrderBy(x => x.GetPropertyValue<string>("Name")) etc...

  • Richard Brookes 34 posts 57 karma points
    Dec 18, 2012 @ 09:35
    Richard Brookes
    0

    Thanks for the reply. Unfortunately I am still getting an error. This time

     

    error CS1061: 'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'ToArray' and no extension method 'ToArray' accepting a first argument of type 'umbraco.MacroEngines.DynamicNodeList' could be found (are you missing a using directive or an assembly reference?)

  • Deci 19 posts 48 karma points
    Apr 11, 2013 @ 18:26
    Deci
    0

    Old thread but I found the answer to a similar problem to be:

    DNL.Items.OrderBy(x => x.GetProperty etc

Please Sign in or register to post replies

Write your reply to:

Draft