Is this query equivalent to a LEFT OUTER join?
//assuming that I have a parameter named 'invoiceId' of type int from c in SupportCases let invoice = c.Invoices.FirstOrDefault(i=> i.Id == invoiceId) where (invoiceId == 0 || invoice != null) select new { Id = c.Id , InvoiceId = invoice == null ? 0 : invoice.Id }
Not quite – since each "left" row in a left-outer-join will match 0-n "right" rows (in the second table), where-as yours matches only 0-1. To do a left outer join, you need
SelectManyandDefaultIfEmpty, for example:(or via the extension methods)