我有这种方法应该按名称搜索员工集合。我传递了我想要查找的姓氏数组,该方法返回具有这些姓名的员工。简单的。
public IQueryable<Employee> GetEmployees(IEnumerable<string> lastNames)
{
var query = Employees.Where(e => lastNames.Contains(e.LastName));
return query;
}
现在我需要更改方法,以便可以传递部分姓氏数组,并获取姓氏与部分姓氏匹配的所有员工。
public IQueryable<Employee> GetEmployees(IEnumerable<string> partialLastNames)
{
// the code above will not work
}
所以如果我的员工有这些名字:Sigourney Weaver、Amanada Beaver、John Smith、Jane Matheson
我通过 partialLastName 数组 ["aver", "math"],它会返回一个匹配的查询:Sigourney Weaver、Amanada Beaver 和 Jane Matheson
我怎样才能做到这一点 ?
谢谢。