Copied to clipboard

Flag this post as spam?

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


  • Jon Dunfee 199 posts 468 karma points
    Jun 25, 2013 @ 18:26
    Jon Dunfee
    0

    Requesting SelectRecursive() Example (v6)

    I'm just not figuring out the proper selector expression to single out a page located under a parent using the SelectRecursive() option and need some assistance.  Here's my code of interest:

    foreach (var item in Items) {
    var kid = contentService.GetDescendants(parentPage).SelectRecursive(p => p.Name.Equals(item.Textpage));

      ... kid does chores here ...
    }

    Cannot convert expression type 'bool' to return type 'System.Collections.Generic.IEnumerable<Umbraco.Core.Models.IContent>'

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Jun 26, 2013 @ 12:44
    Jeroen Breuer
    0

    Hello,

    Do you need to use the conten service for this? If your looking for published content in the website you can use IPublishedContent which might have some better helpers.

    Jeroe

  • Jon Dunfee 199 posts 468 karma points
    Jun 27, 2013 @ 17:23
    Jon Dunfee
    0

    I am using the content service.  After messing around with it, doing the following worked for what I was wanting to do:

    foreach (var item in Items) {
      var kid = contentService.GetDescendants(parentPage).First(p => p.Name.Equals(item.Textpage));

    ... kid does chores here ...
    }

    Apparently GetDescendants() flattens all children to a list compared to GetChildren().  I'd still like to know how to use SelectRecursive() for future reference and to see if it's better performing than what I'm using.  What I have now would at least return me a single IContent than an IEnumerable<IContent>.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies