我正在尝试构建一个简单的搜索,在其中传递关键字列表。但是,只要我将“任何包含关键字”添加为列表而不是字符串,我就会得到:
"DbExpressionBinding requires an input expression with a collection ResultType."
我已经扩展IQueryable<Inspector>
了:
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;
}
当我调用它时,我使用:
return qry.Search(keywords).ToList();
我应该如何解决这个问题?