error CS1061: 'umbraco.NodeFactory.Node' does not contain a definition for 'Descendants' and no extension method 'Descendants' accepting a first argument of type 'umbraco.NodeFactory.Node' could be found (are you missing a using directive or an assembly reference?)
Thanks but no joy I'm afraid. Maybe I should explain what I'm trying to achieve. I need to output JSON for all descendants of a node. I'm using this script which I'm trying to adapt as at hte moment it only returns child nodes
Descendants rather than ChildrenAsList
Is there equivalent code that will get the descendants of a node as a list like this:
node.ChildrenAsList.ToList();
e.g.
node.DescendantsAsList.ToList();
Hi Dan,
You could use .Descendants() the method returning either all pages (children, grandchildren and so on) below a given page in the content tree.
So something like this
You can see the different collections methods here https://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets I know it says for Umbraco 6, but you can also use it for Umbraco 7. It´s just some pdf files with an overview of the different methods.
Hope this helps,
/Dennis
Thanks but it throws this error:
error CS1061: 'umbraco.NodeFactory.Node' does not contain a definition for 'Descendants' and no extension method 'Descendants' accepting a first argument of type 'umbraco.NodeFactory.Node' could be found (are you missing a using directive or an assembly reference?)
Hi Dan,
What if you do something like this:
I found it on stackoverflow here: http://stackoverflow.com/questions/20629673/where-on-specific-node-children-returns-does-not-contain-a-definition-for-where
Hope this helps,
/Dennis
Thanks but no joy I'm afraid. Maybe I should explain what I'm trying to achieve. I need to output JSON for all descendants of a node. I'm using this script which I'm trying to adapt as at hte moment it only returns child nodes
https://our.umbraco.org/projects/website-utilities/node-2-json
is working on a reply...