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.
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?)
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?
you might have some look with the ToArray() method and then revert to linq
eg
DNL.ToArray().OrderBy(x => x.GetPropertyValue<string>("Name")) etc...
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?)
Old thread but I found the answer to a similar problem to be:
DNL.Items.OrderBy(x => x.GetProperty etc
is working on a reply...