I’m trying to grab all users joined with Company
var users = CreateObject<User>();
var companies = CreateObject<Company>();
var companyUsers = users
.Where(u => u.IsEmployee)
.Join(companies, u => u.UserId, c => c.UserId, (u, c) => u.UserId)
.ToList();
Problem: I’m trying to return companyUsers which is of type List and my method’s return type is List that this code is in but I get the error that List cannot be converted to List when I do a return companyUsers for this method.
I figured it’s just a syntax error in that LINQ is trying to return a different type due to a syntax issue in my query that I cannot see.
You are not selecting a user, you are selecting a user ID in your query. The output then is a
List<X>, whereXis the type ofUserId(I presume it’s an int or some other basic type).To fix this issue to get a
List<User>, change your join to produce a different output.