We need to obtain all the real estate listings where the city is one that is specified in the search criteria. I have a search page where a user may input several cities separated by commas. The user may input something like this, for example.
cities are Austin and Dallas
If the user inputs the complete name of the city, my query works as intended.
Dallas and Austin are on the new list "cityList"; the property type is "residential." . AsQueryable Where (x=cityList.Contains(x.City)) is used. ToList();
However, it does not function if I merely type in Dal, Australia. How can I get these partial searches to function? Can Dynamic LINQ be the only solution? Thanks!
var properties = Reporsitory.AsQueryable().Where(x => cityList.Count(c => x.StartsWith(c)) != 0);
Alternately, change StartWith to Contains.