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 21 posts 133 karma points
    Feb 07, 2019 @ 12:47
    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 6163 posts 24143 karma points MVP 8x admin c-trib
    Feb 07, 2019 @ 12:51
    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 6163 posts 24143 karma points MVP 8x admin c-trib
    Feb 07, 2019 @ 13:03
    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 21 posts 133 karma points
    Feb 07, 2019 @ 13:05
    Andrew Hopkins
    0

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

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Feb 07, 2019 @ 13:48
    Alex Skrypnyk
    0

    You are welcome!!!

Please Sign in or register to post replies

Write your reply to:

Draft