Copied to clipboard

Flag this post as spam?

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


  • Joao Baptista 8 posts 58 karma points
    Oct 01, 2014 @ 17:27
    Joao Baptista
    0

    Typed content lambda expression - children could not be evaluated

    Hi

    Umbraco 7.1.6.

    so I'm using a lambda expression to lookup a few nodes but when I try to do a where based on one property value I always get children could not be evaluated.

    code being

    foreach (var productCategory in Umbraco.TypedContent(1115).Children.Where(a => a.HasValue("highlightMapType") && a.GetPropertyValue("highlightMapType") == "Yes" )) ...
    

    the foreach does not execute as nothing is returned. When I debug and inspect the lookup into another variable, where I should get a list of published content I get "children could not be evaluated".

    Now, if I try

    foreach (var productCategory in Umbraco.TypedContent(1115).Children.Where(a => a.HasValue("highlightMapType") ))
    

    this works fine, but still returns unwanted items.

    Not sure if it's a bug but the code can see the property, can see that it has a value, but cannot evaluate it. On the later foreach, where I get all items and then I print out the property value separately I get the property perfectly - "Yes" or "No".

    Casting the generic type to bool will also give me the infamous children could not be evaluated.

    As a last resort I could do an if inside the foreach as I know that I can get the property value, but this would be really inefficient.

    Wondering if it's a bug or an issue that you guys have had and there's a small gotcha?

    Cheers!

  • Joao Baptista 8 posts 58 karma points
    Oct 01, 2014 @ 17:30
    Joao Baptista
    0

    Fixed! For some reason, casting the generic type to string made it work. So as a reference for anybody else:

    @foreach (var productCategory in Umbraco.TypedContent(1115).Children.Where(a => a.HasValue("highlightMapType") && a.GetPropertyValue<string>("highlightMapType") == "Yes" ))
    

    Bizarre as this was my starting point! Oh well, I hope this helps someone else!

  • Øyvind Kristiansen 14 posts 54 karma points
    Mar 20, 2015 @ 12:53
    Øyvind Kristiansen
    0

    Old post, but i found this while googling for "children could not be evaluated", and found a different solution which I thought might help someone else.

    The reason for this error turned out to be that the document cache was corrupted, specifically due to me having changed document type on a document earlier (I love the new option, but I think there might be a bug). I republished the root node, checking "Publish children," and all was OK again.

Please Sign in or register to post replies

Write your reply to:

Draft