Copied to clipboard

Flag this post as spam?

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


  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Nov 30, 2011 @ 17:07
    Dan Diplo
    0

    Multiple Where clauses not same as Where with AND?

    This may well be the correct and intended behaviour, but I was suprised that the following two queries didn't return the same results. Basically I was trying to work out whether any descendant nodes of a top-level page had any nodes that where both visible and with a level greater than three.

    My original query was this:

    bool hasMultipleLevels = topPage.Descendants().
    Where("Visible && Level > 3").Count() > 0;

    However, this didn't return the expected results (it would return 'true' even when the descendant pages where hidden). So I modified my query to this:

    bool hasMultipleLevels = topPage.Descendants().
    Where("Visible").Where("Level > 3").Count() > 0;

    This worked as expected and return "false" when descendant pages where hidden.

    I would have thought the two were conceptually the same? But clearly not! So is this intended or a bug? :)

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Nov 30, 2011 @ 17:36
    Sebastiaan Janssen
    0

    Try Where("Visible == true && Level > 3") as well.. but I would think the first one would indeed check if the item was Visible AND (if that is true THEN) the level is larger than 3.

    So might be a bug, or might be some weird behaviour that doesn't make sense (yet!) to simple people like you and me.. ;-)

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Nov 30, 2011 @ 17:46
    Dan Diplo
    0

    Hi Seb,

    Tried what you suggested but with the same results....

    As you say, probably makes sense to higher beings :)

  • keilo 568 posts 1023 karma points
    Aug 29, 2018 @ 13:07
    keilo
    0

    I came across a similar issue and it seems the following is working in mysterious ways:

    node.Descendants().Where("NodeTypeAlias  == @0 || NodeTypeAlias  == @1", "DocType1", "DocType2").Where("customer==\"\"")
    

    this is only returning results from DocType1 and not from DocType2.

    Background: The node is in ListView, containing the DocType1 and DocType2 and customer is a MNTP (which is empty, doesnt contain any entry).

    If I chage the order such as:

    NodeTypeAlias  == @0 || NodeTypeAlias== @1", "DocType2", "DocType1")
    

    then it only returns the DocType2 but not DocType1.

    Is there anyone who can shed light on why this doesnt work on the second DocType but the first?

  • keilo 568 posts 1023 karma points
    Aug 30, 2018 @ 08:04
    keilo
    0

    For completeness who lands on this page, like me, later;

    Changing to DocumentTypeAlias works ;

    node.Descendants().Where("DocumentTypeAlias == @0 || DocumentTypeAlias == @1", "DocType1", "DocType2").Where("customer==\"\"")
    
  • 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