Copied to clipboard

Flag this post as spam?

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


  • Ed Johnson 8 posts 58 karma points
    Oct 22, 2013 @ 16:56
    Ed Johnson
    0

    Problem with compound statement in 'Where' method

    Hello friends,

    Let me begin by saying that I am new to Umbraco and Razor, so please forgive me if this problem is trivial.

    I am trying to get the "articles" that each author has written, there are several document types that represent these articles and several document types that represent the authors. Obviously, each article document type has an "Author" field where the user can choose the author from a dropdown list for that particular article. However, when I try to retrieve the articles for each author, I can't seem to get all of the document types in the compound statement, let me illustrate:

    var articles= @Model.AncestorOrSelf(1) .Descendants().Where("DocumentTypeAlias==\"PodcastCaseStudy\" || DocumentTypeAlias==\"TextCaseStudy\"");

    This will only return the articles with document type "PodcastCaseStudy" and not "TextCaseStudy". Any ideas as to why this would be the case? We have a similar code structure in a site with an earlier version of Umbraco that works perfectly. However, with Umbraco 6.1.5, this is giving us issues.

    I hope someone can help us, thank you in advance!

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Oct 22, 2013 @ 18:36
    Dennis Aaen
    0

    Hi Ed,

    You could try something like this and see if it works as it should:

    var articles= @Model.AncestorOrSelf(1).Descendants().Where("NodeTypeAlias == @0 || NodeTypeAlias == @1","PodcastCaseStudy","TextCaseStudy")

    You can find the documentation about Filtering, Ordering & Extensions here http://our.umbraco.org/documentation/Reference/Querying/DynamicNode/Collections#Where%28%22condition%22[valueIfTruevalueIfFalse]%29

    Hope this helps you.

    /Dennis

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Oct 28, 2013 @ 19:41
    Dennis Aaen
    0

    Hi Ed,

    Did you try my suggestion and you managed to filter on more than one documentype in you where.condition?

    Looking forward to hear from you.

    /Dennis

     

Please Sign in or register to post replies

Write your reply to:

Draft