Instead, you can use s.Surname.First()
:
if (!string.IsNullOrEmpty(Queries["SurnameInitial"])) { var initials = Queries["SurnameInitial"].Split(','); filter.And(s => initials.Contains(s.Surname.First())); }
This is because Linq to Entities does not know what to do with char.ToString()
Since you are dealing with List<string>
, you can use:
filter.And(s => initials.Any(x => x.Contains(s.Surname.First()));
source share