I have a method in which I'm trying to return some database results through a LINQ query, however Visual Studio is not allowing me to use a select statement. This is what I have so far:
public static int GetCurrentUserDepartmentId(Guid userGuid)
{
int departmentId = -1;
using (PTMS_DataEntities entities = new PTMS_DataEntities())
{
var userDepartment = from employee in entities.Employees
join user in entities.aspnet_Users
on employee.User_Id equals user.UserId
where employee.User_Id equals userGuid
departmentId = (int)userDepartment;
}
return departmentId;
}
However, in the LINQ segment, I would like it to be as follows:
from employee in entities.Employees
join user in entities.aspnet_Users
on employee.User_Id equals user.UserId
where employee.User_Id equals userGuid
select employee.Department_Id
Is there a particular reason why I'm not being allowed to add the last select portion?