title: Left outer joins with Linq-To-Sql
body: <p>I want to use a linq-to-sql query which will use inner joins and left outer joins (using .DefaultIfEmpty()) but the query is not working. This is bugging me as its a simple task in T-SQL. 
  here is my query : </p>
  
  <pre><code>  var results = from cy in _dc.Companies
                        join cyv in _dc.CompanyVersions
                            on cy.CompanyId equals cyv.CompanyId
                        join cyd in _dc.CompanyDetails
                            on cyv.CompanyVersionId equals cyd.Id
                        join cd in _dc.CustomerDetails
                            on cy.CompanyId equals cd.CompanyId
                        join d in _dc.Documents
                            on cd.CustomerId equals d.CustomerId
                        join di in _dc.DocumentItems
                            on d.DocumentId equals di.DocumentId
                        join dd in _dc.DocumentDetails
                            on di.DocDetailsId equals dd.DocumentDetailsId
                        join dt in _dc.DetailTypes
                            on dd.detailTypeId equals dt.detailTypeId
                        join vt in _dc.Vats
                            on dt.VATCode equals vt.VATCode
                        join v in _dc.Vouchers.DefaultIfEmpty()
                            on dd.DocumentDetailsId equals v.DocDetailID
                        join cc in _dc.CreditCards.DefaultIfEmpty()
                            on v.CCType equals cc.CCType
                        where
                            (d.DocTypeId == 1 || d.DocTypeId == 2) &amp;&amp; (d.DocDate &gt;= date)     
                          &amp;&amp;
                            (d.DocDate &lt; date.AddDays(1)) &amp;&amp;
                            (d.CompanyVersionId == cyv.CompanyVersionId)
                            &amp;&amp; (d.isDeleted == false || d.isDeleted == null)
                        orderby d.DocNumber ascending
                        select new
                                   {
                                       d.DocumentId,
                                       d.DocNumber,
                                       d.AutUser,
                                       d.GrossAmount,
                                       d.DocTypeId,
                                       cyd.Name,
                                       cyd.AddressLine1,
                                       cyd.AddressLine2,
                                       cyd.TelephoneLine,
                                       cyd.FaxLine,
                                       v.FromVoucNbr,
                                       d.DocDate,
                                       cd.CustomerName,
                                       cd.StreetAddress,
                                       cd.City,
                                       cd.Country,
                                       dt.DetDescr,
                                       cc.CCType,
                                       dd.FreeDescr,
                                       dd.NetAmount,
                                       dd.VATAmount,
                                       vt.VATDescr,
                                       cc.Description,
                                       vt.VATRate
                                   };
  </code></pre>
  
  <p>can anyone suggest how i can use left outer joins on the last 2 tables in this query?</p>