I am a Cloud subscriber setting up a basic blog. I want to filter the list of blog articles by author, but I am having a hard time with querying a collection on the value of a property that has properties of its own. "Author" is a document type. "Article" is a document type that has a custom ContentPicker for selecting an "Author". I have the following code in my view template:
var articles = Umbraco.Content(Guid.Parse("654c40f6-187e-4fa7-a68e-00ce50e7aa9c"))
.Children<Article>("article")
.Where(x => x.IsVisible())
.OrderByDescending(x => x.Value<DateTime>("publishDate"));
var requestQueryString = String.Empty;
// If author parameter is selected, narrow articles to author in Request query author parameter
if(!string.IsNullOrEmpty(HttpContextAccessor.HttpContext.Request.Query["author"]))
{
requestQueryString = HttpContextAccessor.HttpContext.Request.Query["author"];
// Everything works until I try to filter by author
articles = articles.Where(a => a.Author.Key == requestQueryString);
}
I'm not sure how I would achieve this in Umbraco. Any insights are greatly appreciated. Thank you. :)
Query by Property of a ContentPicker Property
I am a Cloud subscriber setting up a basic blog. I want to filter the list of blog articles by author, but I am having a hard time with querying a collection on the value of a property that has properties of its own. "Author" is a document type. "Article" is a document type that has a custom ContentPicker for selecting an "Author". I have the following code in my view template:
I'm not sure how I would achieve this in Umbraco. Any insights are greatly appreciated. Thank you. :)
is working on a reply...