Copied to clipboard

Flag this post as spam?

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


  • Steve 472 posts 1216 karma points
    Nov 30, 2015 @ 19:38
    Steve
    0

    Filtering using Where Method and Multiple Tests

    I can't seem to get the syntax correct for this to work. I have 3 things I want to test for using the Where(). Could someone help me out?

    Test for "Visible" (umbracoNaviHide) Test if property "secondaryNavGroup" is checked (true/false) Test if the NodeTypeAlias is alias of type "ExernalLink"

    var root =  Model.AncestorOrSelf(2);
    var listings = root.Children.Where("Visible && secondaryNavGroup != true || NodeTypeAlias == \"ExternalLink\"").Take(12);
    
  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Nov 30, 2015 @ 20:25
    Dan Diplo
    0

    I would write it like this:

    var listing = root.Children().Where(x => (x.Visible && !x.GetPropertyValue<bool>("secondaryNavGroup")) || x.NodeTypeAlias == "ExternalLink").Take(12);
    

    I've not tested, but that is the gist.

  • 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