gpt4 book ai didi

.net - linq 等效 SQL 查询 "not in (select query)"

转载 作者:行者123 更新时间:2023-12-01 16:45:33 25 4
gpt4 key购买 nike

我的sql代码如下:

select UserId,UserName 
from aspnet_Users
where UserId not in (select UsersId from tbluser where active='true')

等效的 linq 表达式是什么?

最佳答案

我第一次尝试在 C# 中使用 LiNQ

var result = from y in aspnet_Users
where !(
from x in tblUser
where x.active == "true"
select x.UsersID
).Contains(y.UserId)
select y;
-- OR // select new { y.UserId, y.UserName};

来源

关于.net - linq 等效 SQL 查询 "not in (select query)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14001588/

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