This is my function:
Public Function GetAllEmployee() As List(Of Employees)
Return DB.Employees.Select(Function(q) New With {q.EmployeeID, q.LastName,q.FirstName}).ToList()
End Function
I’m getting an error:
Value of type
System.Collections.Generic.List(Of <anonymous type>)cannot be converted toSystem.Collections.Generic.List(Of NorthwindModel.Employees).
You’re instantiating an Anonymous object inside your select statement. Try using this:
EDIT: If you want to give back a list of objects with only those 3 properties, you can define a class containing those properties:
Then return a list of that new class: