I'm trying to build a simple search where I pass a list of keywords. But soon as I add the "any contains keywords" as a list instead of a string I get:
"DbExpressionBinding requires an input expression with a collection ResultType."
I have extended IQueryable<Inspector>
with:
public static IQueryable<Inspector> Search(this IQueryable<Inspector> qry, List<string> keywords)
{
return from i in qry
where
i.LastName.Any(x => keywords.Contains(i.LastName)) ||
i.FirstName.Any(x => keywords.Contains(i.FirstName)) ||
i.City.Any(x => keywords.Contains(i.City)) ||
select i;
}
And when I call it I use:
return qry.Search(keywords).ToList();
How should I fix this issue?
I think you're trying to get at this:
This will return you any records where the FirstName, LastName, or City is in your keyword list.