title: Select values from one table based on specific value of another table Linq
body: <p>I have 2 tables:</p>
  
  <pre><code>            Location
   id  | user_id | latitude | longitude|
    1  |    2    | 11.32323 | 11.32323 |
    2  |    3    | 12.32323 | 12.32323 | 
    3  |    4    | 21.32323 | 12.32323 |
  </code></pre>
  
  <hr>
  
  <pre><code>           Task
   id  | user_id | status |
    1  |    2    |   0    |
    2  |    2    |   1    |
    3  |    2    |   0    |
    4  |    2    |   2    |
    5  |    2    |   1    |
    6  |    2    |   0    |
    7  |    3    |   1    |
    8  |    3    |   1    |
    9  |    3    |   1    |
  </code></pre>
  
  <p>I want to select all rows from location table in which users have </p>
  
  <ul>
  <li>either no record in Tasks table <em>(for e.g. user_id = 4)</em>  </li>
  <li>or if records
  exists then all of them <strong>must</strong> have status equals to 1 <em>(for e.g. user_id
  = 3)</em>.</li>
  </ul>
  
  <p>In above example, user_id = 2 should not be selected because it has rows in Tasks table with status other than 1.</p>
  
  <p>I am not very much familiar with SQL and LINQ so any help would be appreciated.</p>
  
  <p>This is the expected result:</p>
  
  <pre><code>            Result
   id  | user_id | latitude | longitude|
    2  |    3    | 12.32323 | 12.32323 | 
    3  |    4    | 21.32323 | 12.32323 |
  </code></pre>
  
  <ul>
  <li>Location with user_id = 2 was <strong>ignored</strong> because it has some rows in Tasks table with status other than 1.</li>
  <li>Location with user_id = 3 was <strong>selected</strong> because all rows in Tasks table has status = 1.</li>
  <li>Location with user_id = 4 was <strong>selected</strong> because there were no rows in Tasks table with user_id = 4.</li>
  </ul>