I have got 3 table.
For instance Client, Company and Address.
Client has got ref to Company.
Company has got 2 nullable refs to Address (Billing and Shipping), so Address may not exist in some case.
I need make join query, but in case when Company.BillingAddress
or Company.ShippingAddress
equals null
, I don't get all data).
I tried it (but it's wrong query):
var res = (from client in context.Clients
join clientCompany in context.Companies
on client.ClientCompanyId equals clientCompany.Id
into clientCompanyJoin
from company in clientCompanyJoin
join addressBilling in context.Addresses
on company.BillingAddressId equals addressBilling.Id
join addressShipping in context.Addresses
on company.ShippingAddressId equals addressShipping.Id
select new
{
Client = client,
Company = company,
BillingAddress = ???????
ShippingAddress = ???????
}
);
Could you please help me to make a join query or explain how to do it?
Thanks.