Пример #1
0
        public static DynamicCollection <DynamicPerson> GetPersonsBySearchTerm(this DynamicCollection <DynamicPerson> persons, string searchTerm)
        {
            // [V] Smarter search logic - Fuzzy search - Consecutive letters
            // [X] Searching in english tries to convert characters to hebrew and search
            // [X] But if the searched string is in english, search in english
            // [X] Try to order by relevance (SearchAll should return a float which represents how good is the match)

            string[] whiteSpaces = { " " };
            string[] searchTerms = searchTerm.Split(whiteSpaces, StringSplitOptions.RemoveEmptyEntries);

            // Return all persons, for which all the search terms appear in their properties
            return(new DynamicCollection <DynamicPerson>(persons
                                                         .Where(person => person.SearchAll(searchTerms))
                                                         .ToList()));
        }