Copied to clipboard

Flag this post as spam?

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


  • Andrew Hopkins 5 posts 75 karma points
    1 week ago
    Andrew Hopkins
    0

    Querying a multinode treepicker control if it contains a value

    I am trying to query a list of documents which contain a list of author names stored in a Multinode Treepicker control.

    var data = Model.Content.Site().FirstChild("Article").Children("Articles").Where(x => x.IsVisible() && x => x.GetPropertyValue<IEnumerable<string>>("pageAuthors").Contains("Peter Smith")).OrderBy("pageDate desc");
    

    What am I doing wrong? Any suggestions?

    Thanks

  • Alex Skrypnyk 4975 posts 18106 karma points MVP 2x admin c-trib
    1 week ago
    Alex Skrypnyk
    100

    Hi Andrew

    Try this code:

        var data = Model.Content.Site()
            .FirstChild("Article")
            .Children("Articles")
            .Where(x => x.IsVisible() && x.GetPropertyValue<IEnumerable<string>>("pageAuthors").Contains("Peter Smith"))
            .OrderByDescending(x => x.GetPropertyValue<DateTime>("pageDate"));
    

    Thanks,

    Alex

  • Alex Skrypnyk 4975 posts 18106 karma points MVP 2x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

    There is a syntax mistake in your code here:

    .Where(x => x.IsVisible() && x => x.
    

    no need second " x => "

    And OrderByDescending I changed a bit

    Thanks,

    Alex

  • Andrew Hopkins 5 posts 75 karma points
    1 week ago
    Andrew Hopkins
    0

    Many thanks, Alex, I really appreciate your help :)

  • Alex Skrypnyk 4975 posts 18106 karma points MVP 2x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

    You are welcome!!!

Please Sign in or register to post replies

Write your reply to:

Draft