I am trying to sort a DynamicNodeList by a numeric property “cost”. I’ve tried loads of different ways here but am completely at a loss:
var nodes = Model.AncestorOrSelf(1).Descendants().Where("NodeTypeAlias.Equals(\"Event\")").Where("Visible");
nodes = nodes.OrderBy("Int32.Parse(cost.Value)");
Gives me the error: No property or field ‘Value’ exists in type ‘Func`2’
I’ve got a feeling this is as close as I’ve gotten! Does anybody have any clues on this?
EDIT:
OK I solved this by changing the NodeList:
var nodes = Model.AncestorOrSelf(1).Descendants().Where("NodeTypeAlias.Equals(\"Event\")").Where("Visible").Where("cost > 0");
…should work just fine.
Refer to Umbraco Razor Feature Walkthrough – Part 4 for more info on
OrderBy().