Function searchByName(lName As String) As List(Of Employees)
Dim employees As New Employees
Dim employeeList As New List(Of Employees)
Dim resultList As New List(Of Employees)
employeeList = employees.getEmployeeObject
resultList = From employeesObj In employeeList
Where employeesObj.LastName = lName
Select employeesObj.EmployeeID
Return resultList
End Function
答案 0 :(得分:0)
大多数Linq方法的结果(也适用于此处使用的内置理解语法)是IEnumerable(Of T)
而不是List(Of T)
。为了返回表达式的结果,您需要将结果放入列表中,最常见的方法是在生成的ToList
引用上调用IEnumerable(Of Employees)
扩展方法。< / p>
例如:
resultList = From employeesObj In employeeList
Where employeesObj.LastName = lName
Select employeesObj.EmployeeID
Return resultList.ToList()