I have 3 tables. master, consumer& charge. invoiceid is pk for master which exists in consumer&charge table. consumer pk is consumerid & invoiceid. charge pk is charge id and fk is consumer id. I am trying to display columns from all the tables but some consumer id does not show up when displayed as there is no row referring to it in the charge table. I have tried to do left join but still does not display. Any suggestions?
Edit:
So I have figured out on how to do one left join but how do I do it if for 3 tables? I am able to display consumerid where there is no entry in charge but can't get invoiceid where there is no entry in consumers. A master may or may not have a consumer and a consumer may or may not have a charge. .
var query = from m in IM.GetMaster()
join co in CM.GetConsumers()
on m.InvoiceId equals co.InvoiceId
join ch in CCM.GetCharge()
on new { co.InvoiceId, co.ConsumerId }
equals new { ch.InvoiceId, ch.ConsumerId } into temp
from ch in temp.DefaultIfEmpty()
select new {
InvioceID = m.InvoiceId,
ConsumerID = co == null? 0 : co.ConsumerId,
ChargeID = ch == null ? 0 : ch.ChargeId,
Amount = ch == null ? 0 : ch.Amount
};