Copied to clipboard

Flag this post as spam?

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


  • Renaldas 26 posts 56 karma points
    Feb 24, 2014 @ 16:11
    Renaldas
    0

    v7 how to filter IContent by using WebAPI

    Help please :)

    I trying to filter out content pages by multiple categories:

    I have Umbraco.DropDownMultiple in frontend, using webAPI storing these values in List<string>

    but how to filter out them regards what categories or multicategories selected, my code below:

    List in the model: public List<string> Category { get; set; } 

     var pages = Services.ContentService.GetDescendants(3000); 

    pgs = pages.Where(x => x.GetValue("mycat").ToString() == Category.FirstOrDefault()); - filtering just by first one. but how to filter using all Category list? Thank you

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Feb 24, 2014 @ 17:12
    David Brendel
    0

    Not quite sure right now but shouldn't

    pages.Where(x => Category.Contains(x.GetValue("mycat").ToString())
    

    just work?

  • Renaldas 26 posts 56 karma points
    Mar 03, 2014 @ 16:15
    Renaldas
    0

    No, I wanted to search by more categories at once, ended doing foreach.

     

    Thanks

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies