我必須列出所有要分配給「僱員」的「班次」數據,但如果班次數據已存在於員工數據中,則不得包含班次數據。讓我們看看圖像樣本。如何選擇哪裏不存在使用LINQ?
這個查詢解決了這個問題。我發現這個在這裏:
Scott's Blog
select * from shift where not exists
(select 1 from employeeshift where shift.shiftid = employeeshift.shiftid
and employeeshift.empid = 57);
讓我們看到的結果是:
現在的問題是,我怎麼可能讓這個在LINQ?我正在使用實體框架。
希望有人能幫助。非常感謝!!!
你可以簡單地做一個加入...如果有合適的記錄不存在,左記錄應不包括 – 2012-01-27 09:09:10
@AndreasNiedermair你能舉一些例子嗎?我做了很多加入,但我沒有得到正確的。 – fiberOptics 2012-01-27 09:11:41
可能重複的[LINQ - Where exists](http://stackoverflow.com/questions/899090/linq-where-not-exists) – 2012-01-27 09:16:41