Copied to clipboard

Flag this post as spam?

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

  • Tony Davis 2 posts 72 karma points
    20 days ago
    Tony Davis

    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:

    var articles = Umbraco.Content(Guid.Parse("654c40f6-187e-4fa7-a68e-00ce50e7aa9c"))
            .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
        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. :)

Please Sign in or register to post replies

Write your reply to: