我正在尝试编写相当于的LINQ语句:
select e.EmployeeID,EmployeeName = e.FirstName + ' ' + e.LastName from Employees e where e.EmployeeID not in ( select EmployeeID from Managers )
我想我与以下内容非常接近:
from e in Employees where e.EmployeeID != // This is where I'm lost ( from m in Managers select m.EmployeeID ) select new { e.EmployeeID,EmployeeName = e.FirstName + ' ' + e.LastName }
我想把它放到Html.DropDownList中.
解决方法
我不确定对此的正确查询符号是什么,但以下扩展语法将完成工作
var result = Employees .Where( e => !Managers.Where(m => m.EmployeeId == e.EmployeeId).Any()) .Select( e => new { EmployeeId = e.EmployeeId,EmployeeName = e.FirstName + ' ' + e.LastName);