title: Joining two lists in LINQ
body: <p>Suppose I have two Lists of locations. First has all available locations:</p>
  
  <pre><code>List&lt;Location&gt; locations = new List&lt;Location&gt; {
     new Location { id = 1, address = "1 Main St.", selected = false },
     ...
  }
  </code></pre>
  
  <p>and another is a List or Array of <em>my</em> locations:</p>
  
  <pre><code>List&lt;int&gt; myLocations = new List&lt;int&gt; { 1, 5, 8 };
  </code></pre>
  
  <p>(IDs are unpredictable, but my locations are guaranteed to be a subset of all locations).</p>
  
  <p>I want to outer join two lists and get a result with <code>selected = true</code> for the locations <code>where locations.id eq myLocation</code>s.</p>
  
  <p>If I use Join() or Zip() then I get <em>inner join</em>, in other words, I lose elements that do not exist in myLocations, and if I use the following -</p>
  
  <pre><code>var result = from loc in locations
      join my in myLocations
         on loc.id equals my into myloc
      from m in myloc.DefaultIfEmpty()
         select new Location {
            id = loc.id, address = loc.address, selected = true
         };
  </code></pre>
  
  <p>then <strong>all</strong> locations are marked as selected; not to mention that it looks excessively complex.
  Is there a way to do what I want without looping through list elements?</p>