Copied to clipboard

Flag this post as spam?

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


  • Steve 140 posts 321 karma points
    Jun 25, 2015 @ 18:51
    Steve
    1

    Select Nodes by property value of child nodes

    Hi, I'm trying to select a group of nodes using a 'where' clause which evaluates a property value in the children of each node. That is to say it would select a group of parents which had at least one child node containing the specific value. Not having any luck so far. Code is in a user control (VB in this case) Thanks for any help - Steve

  • René Pjengaard 118 posts 702 karma points c-trib
    Jun 25, 2015 @ 19:40
    René Pjengaard
    0

    Hi Steve,

    i think you will have to show some code before anyone will be able to help you.

    /René

  • Steve 140 posts 321 karma points
    Jun 25, 2015 @ 19:45
    Steve
    0

    Here's what I've got cooking:

     Dim ModelNodesForGrid = From n In New UmbracoHelper(UmbracoContext.Current).TypedContent(ModelOverviewNode.Id).Descendants.AsEnumerable()
                                     Where n.DocumentTypeAlias = "Model" And n.Children.AsEnumerable().Where(n.GetPropertyValue("")) = ""
                                     Select n
                                     Order By n.SortOrder
    

    obviously that's not working but is the idea I want the "model" nodes where at least one of their children have a certain value (in this case flagged as 'active' with a true/false property) thanks!

  • Martin Willis 7 posts 81 karma points
    Jun 30, 2015 @ 22:06
    Martin Willis
    0

    Hi Steve

    I would usually write this in C#, but here goes :

        Dim ModelNodesForGrid = 
        From n In New UmbracoHelper(UmbracoContext.Current).TypedContent(ModelOverviewNode.Id).Descendants("Model") 
        Where n.Children.Any(Function(c As IPublishedContent) c.GetPropertyValue(Of Boolean)("Active") = True)
        Select n
        Order By n.SortOrder
    

    Havent got any way of testing this, all the best.

  • Steve 140 posts 321 karma points
    Jun 30, 2015 @ 03:17
    Steve
    0

    Hi,
    Just wondering if anyone had a chance to take a look or needed more code/description of the desired node selection.
    Thanks, Steve

Please Sign in or register to post replies

Write your reply to:

Draft