gpt4 book ai didi

asp.net-mvc - Linq Select语句-不在何处

转载 作者:行者123 更新时间:2023-12-04 13:30:06 25 4
gpt4 key购买 nike

我正在尝试写等效于以下内容的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);

关于asp.net-mvc - Linq Select语句-不在何处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1015081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com