Copied to clipboard

Flag this post as spam?

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


  • Eran 292 posts 436 karma points
    Sep 07, 2011 @ 03:13
    Eran
    0

    how to use node.Descendants() and Where()

    hi,

    this code is working fine:

    node.Children.Where("disable != true").Where("Level <= maxLevels", values);

     (BTW, node is from type dynamic)

    but it get only the childrens. i want also to get the grand-childrens, etc.

    i know that i need to use with Descendants, but i cant make it work with the above WHERE statment.

    thanks.

  • Eran 292 posts 436 karma points
    Sep 10, 2011 @ 15:28
    Eran
    0

    anybody?

    thanks

  • Sebastiaan Janssen 4876 posts 14545 karma points MVP admin hq
    Sep 12, 2011 @ 17:25
    Sebastiaan Janssen
    0

    You should just be able to replace Children with Descendants()

    If that doesn't work, make sure to get umbraco.RazorEngines.dll from a recent nightly and put it in your /bin folder.

  • Eran 292 posts 436 karma points
    Sep 13, 2011 @ 01:38
    Eran
    0

    thanks, that solved it.

    the problem was the syntax. 

    while this code is working:

    var items = node.Children.Where("disable != true");

    if figured it up that this one should work also:

    var items = node.Descendants.Where("disable != true");

    but it didnt.. because of the missing brackets after Devendants.
    this is the working version:

    var items = node.Descendants().Where("disable != true");
  • Sebastiaan Janssen 4876 posts 14545 karma points MVP admin hq
    Sep 13, 2011 @ 12:10
    Sebastiaan Janssen
    0

    Yes, I understand this can be a bit confusing. I'm not sure why Children is not a method, but Descendants is. Glad it solved your problem though! 

Please Sign in or register to post replies

Write your reply to:

Draft