Lambda 表达式帮助
我有一个问题如何编写 lambda 表达式,我让它在 mssql 查询中工作,如下所示:
SELECT KUNDNR
FROM halldb.dbo.KUND
wWHERE NOT EXISTS
(
SELECT KundID
FROM halldb.dbo.KundInfo
WHERE KUNDNR = CONVERT(Varchar(50), KundInfo.KundID)
)
ORDER BY KUNDNR
我尝试使用 lambda 表达式是这样的:
db.KUNDs.Select(x => x).Except(db.KundInfos.Select(x => x));
但由于 KUNDs 和 KundInfo 是两种不同类型的对象,无法工作...我可以这样:
db.KUNDs.Select(x => x.KUNDNR).Except(db.KundInfos.Select(x => x.KundID.ToString()));
但这只会给我一个包含 KUNDs.KUNDNR 字符串的列表,当我真的想获取一个包含 KUNDs 对象的列表时。
我该怎么做?
非常感谢帮助!
I have a question how to write a lambda expression, i have it working in a mssql query like this:
SELECT KUNDNR
FROM halldb.dbo.KUND
wWHERE NOT EXISTS
(
SELECT KundID
FROM halldb.dbo.KundInfo
WHERE KUNDNR = CONVERT(Varchar(50), KundInfo.KundID)
)
ORDER BY KUNDNR
And what i was trying using lambda expression was this:
db.KUNDs.Select(x => x).Except(db.KundInfos.Select(x => x));
But since KUNDs and KundInfo is two different kind of objects that wont work...i could go like this:
db.KUNDs.Select(x => x.KUNDNR).Except(db.KundInfos.Select(x => x.KundID.ToString()));
But that would just give me a list with strings with KUNDs.KUNDNR when i would really like to get a list with KUNDs objects back.
How can i do this?
Help would be very appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)