Reputation: 5150
I have two tables:
Network_Clients
Clients
Network_Clients has three columns
networkClientID: Key
Name: Varchar
Description: Varchar
Client has 4 columns:
clientID: Key
networkClientId: FK to Network_Clients -> networkClientID
Name: Varchar
Description: Varchar
Clients Table:
clientID networkClientID name description
1 2 Client1 Client of Client2
2 3 Client1 Client of Client3
3 3 Client4 Client of Client3
4 1 Client4 Direct Placement Client
5 1 Client1 Direct Placement Client
Network Clients Table:
networkClientID name description
1 Direct Placer NULL
2 Client2 Network Client Client2
3 Client3 Network Client Client3
4 Test One Test One Network Client
Here is my LINQ query:
from cn in Clients_Network
join c in Clients on cn.networkClientID equals c.networkClientID
select new { cn, c }
This returns everything but Direct Placer
and Test One
because neither of those have a linked field in the Clients table.
How can I get those two to show up?
Upvotes: 1
Views: 68
Reputation: 236238
Use group join (i.e. join...into):
from cn in Clients_Network
join c in Clients on cn.networkClientID equals c.networkClientID into g
from cc in g.DefaultIfEmpty()
select new { cn, cc }
Thats an equivalent of left join in SQL
Upvotes: 4