example of string array stored in DB = "SA|IL|RC|AL|IN" per residence
User can search on specific option
allResidence = allResidence.Where(x => x.LivingOptions.Split('|', StringSplitOptions.RemoveEmptyEntries).Contains(searchCriteria.LivingOptionCode));
this causes an issue if user searches on I - i want it to return 0 but using Contains will obviously return IL & IN as valid options
so how to split and check for specific entry
tried using Equals
allResidence = allResidence.Where(x => x.LivingOptions.Split('|', StringSplitOptions.RemoveEmptyEntries).Equals(searchCriteria.LivingOptionCode));
but that returns 0 when searching for IL example
CodePudding user response:
answer provided by @DemetriusAxenowski
allResidence = allResidence.Where(x => x.LivingOptions.Split('|', StringSplitOptions.RemoveEmptyEntries).Any(x => x == searchCriteria.LivingOptionCode))