title: How to write two left joins in the linq
body: <pre><code>   var CCEScholasticTests = db.CCEScholasticTests.Where(x =&gt; x.CCEvaluationID == CCEValuationID &amp;&amp; x.SubjectID == SubjectID &amp;&amp; x.ClassID == ClassID &amp;&amp; (x.BranchSectionID == BranchSectionID || BranchSectionID == 0) &amp;&amp; x.languageTypeSubjectID == languageTypeSubjectID &amp;&amp; (x.BranchID == BranchID || x.BranchID == 0) &amp;&amp; x.IsOnlyGrade == false).Select(x =&gt; x).ToList();
  var res = (from a in CCEScholasticTests
                                 join b in db2.CCESubjectSkills on new { key1 = a.CCESubjectSkillID } equals new { key1 = b.CCESubjectSkillID } into join1
                                 from joinRes in join1.DefaultIfEmpty(new CCESubjectSkill())
                                 join c in db2.CCEScholasticSkillsMasters on new { key = joinRes.CCEScholasticSkillMasterID } equals new { key = c.CCEScholasticSkillMasterID } into join2
                                 from joinRes2 in join2.DefaultIfEmpty(new CCEScholasticSkillsMaster())
                                 select new EvaluationBluk
                                 {
                                     BranchSectionID = a.BranchSectionID,
                                     CCEScholasticTestID = a.CCEScholasticTestID,
                                     CCEScholasticTestName = a.CCEScholasticTestName,
                                     //CCESubjectSkillName = joinRes.CCESubjectSkillName,
                                     CCESubjectSkillID = a.CCESubjectSkillID,
                                     CCEvaluationID = a.CCEvaluationID,
                                     MaxMarks = a.MaxMarks,
                                     SubjectID = a.SubjectID,
                                     TestDate = a.TestDate,
                                     MarksEntryLastDate = a.MarksEntryLastDate,
                                     //CCEScholasticSkillMasterID = joinRes.CCEScholasticSkillMasterID,
                                     //CCEScholasticSkillName = joinRes2.CCEScholasticSkillName
                                 }).ToList();
  </code></pre>
  
  <p>how to write multiple left joins in linq.. the below linq query i am writing based on this sp</p>
  
  <pre><code>CREATE procedure [dbo].[GetClassCCEScholasticTestsOnlyMarksTest]                
  (             
  @BranchSectionID int,                        
  @CCEvaluationID int,                      
  @SubjectID int,                    
  @ClassID int ,                
  @languageTypeSubjectID int ,          
  @BranchID int                     
  )                        
  as                        
  select c1.BranchSectionID,c1.CCEScholasticTestID,c1.CCEScholasticTestName,s1.CCESubjectSkillName,                        
  c1.CCESubjectSkillID,c1.CCEvaluationID,c1.MaxMarks,c1.SubjectID,convert(varchar,c1.TestDate,101) as TestDate,convert(date,c1.MarksEntryLastDate,101)as MarksEntryLastDate                        
  ,isnull(s1.CCEScholasticSkillMasterID,-1) as CCEScholasticSkillMasterID ,cm.CCEScholasticSkillName     
  
  from dbo.CCEScholasticTests c1                          
  left join CCESubjectSkills s1 on s1.CCESubjectSkillID=c1.CCESubjectSkillID      
  left join CCEScholasticSkillsMaster cm on cm.CCEScholasticSkillMasterID=s1.CCEScholasticSkillMasterID                      
   where  c1.CCEvaluationID=@CCEvaluationID  and c1.SubjectID=@SubjectID                      
   and c1.ClassID=@ClassID and (c1.BranchSectionID=@BranchSectionID or c1.BranchSectionID=0) and c1.languageTypeSubjectID =@languageTypeSubjectID             
   and (c1.BranchID=@BranchID or c1.BranchID=0)and c1.IsOnlyGrade=0        
   order by c1.CCEScholasticTestID asc
  </code></pre>
  
  <p>in sql it throws 3 rows but in linq it throws 1 row only... what wrong in my code</p>