,我有以下數據:如何執行左外連接具有鮮明的條款
用戶:
Id UserId Name
----------------
1 1 Him
2 10 Her
3 2 Other
組:
Id GroupId UserId
-------------------
1 1 1
2 2 2
3 3 10
在SQL我可以做些什麼像這樣來確定用戶是否在任何組
select *
from Users as u
left outer join (select distinct(UserId) from Groups) as g on u.UserId = g.UserId
結果應該是這樣的。
Id UserId Name UserId
------------------------
1 1 Him 1
2 10 Her 10
3 2 Other Null
但我怎麼能在LINQ中做到這一點?
一個「用戶ID」通常是本質上是不同的值,你可能甚至不需要明確的條款 – Alex