title: How to force Linq to join tables
body: <p>I'm using EF 4.1 and a database I didn't design. I have two tables</p>
  
  <pre><code>TableA
  [
    TableAKey,
    OtherField
  ]
  
  TableB
  [
    TableBKey,
    TableAKey, &lt;-- Foreign Key
    OtherField
  ]
  </code></pre>
  
  <p>The problem I have is that the foreign key does not get nulled when the parent record is deleted.  This is something I have no control over and can't change.  When selecting from TableB I want to exclude all the rows with missing TableA records.</p>
  
  <p>In SQL this is easy with a simple INNER JOIN.  However the linq below doesn't join the tables.  I guess it's optimising the SQL.  The below code generates SQL that has no mention of TableA.  Maybe because I don't return anything from it.</p>
  
  <pre><code>(from b in TableB
  join a in TableA on b.TableAKey equals a.TableAKey
  where b.OtherField == something
  select b).ToList();
  </code></pre>
  
  <p>Is there any way to force a SQL join or a better way of doing this.</p>
  
  <p>Cheers</p>