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.
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!
Hi Ed,
You could try something like this and see if it works as it should:
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
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
is working on a reply...