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!
db.KUNDs.Where(k => !db.KundInfos.Any(ki => k.KUNDNR == ki.KundID.ToString()))
.OrderBy(k => k.KUNDNR);
精彩评论