asp.net-mvc – Linq选择语句 – 不在的地方

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – Linq选择语句 – 不在的地方前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试编写相当于的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);
原文链接:https://www.f2er.com/aspnet/246915.html

猜你在找的asp.Net相关文章