Copied to clipboard

Flag this post as spam?

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


  • mike 90 posts 258 karma points
    Mar 05, 2015 @ 23:19
    mike
    0

    Getting Nested Children

    Hi.

    I have structure setup like this in my site:

    Home
      - Testimonials
          - Testimonial 1
          - Testimonial 2
          - Testimonial 3

    The testimonials document type is purely there to act as a container so I can enable list view to look at all the testimonials and manage them.

    On the homepage I am then trying to populate an object with all the testimonials but I am unable.  Any variation of @Model.Content.Children or @Model.Content.Children.Where(...) returns nothing and in debugger I get message:

    "Children could not be evaluated"

    I have also tried .Descendants().  Same thing.  What am I missing here?

     

     

  • mike 90 posts 258 karma points
    Mar 05, 2015 @ 23:34
    mike
    0

    It works with:

    var testimonials = @CurrentPage.Descendants("Testimonial");
    

    I don't understand why dynamic query works and strongly typed one does not.  Is it something to do with the cache?

    Can anyone explain this for my own understanding and learning?

  • mike 90 posts 258 karma points
    Mar 06, 2015 @ 02:31
    mike
    0

    Turns out its an EF issue with lazy loading.  Adding .ToList() makes it viewable in the debugger.  Not sure why my code wasn't working originally.  I have got it working with strongly typed query now.

Please Sign in or register to post replies

Write your reply to:

Draft