title: Entity Framework left outer join not working
body: <p>I have an Entity Framework model with the following classes (I have simplified the classes for simpler viewing):</p>
  
  <pre><code> PuzzleItem
   -PuzzleId (int, primary key)
   -Title
  
   PuzzleProgress
   -ProgressId (int, primary key)
   -PuzzleId (FK)
   -UserId (FK)
  </code></pre>
  
  <p>In <code>PuzzleItem</code> I have a number of levels. The <code>PuzzleProgress</code> keeps track of which level the user is at by inserting a record of that level when the user completes a previous level. For a start a new user will have one entry in <code>PuzzleProgress</code> with <code>PuzzleId = 1</code>.</p>
  
  <p>In my code, I am using the following statement to perform a left outer join, so that I will get a list of all puzzles, and indicating to me which puzzle has not been solved. I made reference to <a href="https://stackoverflow.com/questions/9500103/converting-a-left-outer-join-to-entity-framework">this post from StackOverflow</a>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>var result = from pzs in e.PuzzleItems
                           join prg in e.PuzzleProgresses on pzs equals prg.PuzzleItem
                           into pzs_prg_tbl
                           from pzs_prg in pzs_prg_tbl.DefaultIfEmpty()
                           where pzs_prg.UserId == userId
                           select new SimplePuzzleItem()
                           {
                               PuzzleId = pzs_prg.PuzzleId,
                               PuzzleName = pzs_prg.PuzzleItem.Title,
                               IsUnlocked = (pzs_prg == null?false:true)
                           };
  </code></pre>
  
  <p>After running the code, only the first level of this new user is returned (while the <code>PuzzleItem</code> table has 3 records). </p>
  
  <p>I've tried playing around with the code but the one I pasted above is the nearest I can get to, can anybody point me in the correct direction? Thanks!</p>