Copied to clipboard

Flag this post as spam?

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

  • Edvin 9 posts 99 karma points
    Feb 14, 2019 @ 17:40

    Filtering Repeatable String Property in Linq


    so I am having a custom search form, basically the user types in a keyword and I search the collection of Persons based on his properties and if they contain the keyword.

    So user types in "Berlin" and I filter all persons which contain the keyword in there property:

            var filteredMedia = Model.Persons.Where(x => x.GetPropertyValue<string>("city").ToUpper().Contains(searchTerm.ToUpper())).Reverse();

    So this works great with normal text string fields, but if I use the repeatable string, then I have a problem. I can't use the GetPropertyValue

    I am currently fixed this by doing it the "manual" way, getting the collection and filter out the ones through two for each loops, but I am afraid that could be a bit slow.

    Any Ideas how I could filter out the repeatable strings directly throught Linq?


  • Matthew Wise 265 posts 1282 karma points MVP 3x c-trib
    Feb 18, 2019 @ 07:36
    Matthew Wise

    Hi Edvin,

    Repeatable text string should return an array so updating your where clause to -


    I would also recommend null checking x in case someone unpublished a Person that is selected.


Please Sign in or register to post replies

Write your reply to: