Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi just using umbraco 8 and the query builder.
When I select the content type, it just returns all nodes regardless.
.Where(x => x.IsVisible())
Just returns all the prime nodes. and not the ones I actually want.
Have I missed something ?
Try this code:
var socialLinks = Umbraco.ContentAtRoot().FirstOrDefault().Children().Where(x => x.IsVisible()).OfType<SocialLink>();
.Children("socialLink") doesn't work in v8, you can't get all nodes of specified document type. Try to use ModelsBuilder and OfType
So the query builder is now defunct ? What is modelsbuilder ?
No, just Children by doctype as a string doesn't work.
Ok just ammended it to..
var socialLinks = Model.Root().Descendants().Where(x => x.IsVisible()).OfType<SocialLink>();
I take it this is the correct way to get all regardless of level.
Now one last quesiton where would I research your solution ie' how would I know to have used .OfType
Thanks for your help Alex
Rob, the information should be here - https://our.umbraco.com/Documentation/Reference/Querying/IPublishedContent/Collections
Cheers, looking at the wrong one :) Thanks.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted