title: Linq intersect or join to return items from one collection that have matching properties to another?
body: <p>I have the following scenario:  Two lists of different <code>Types</code> which happen to contain 3 matching properties (in reality, the names are not the same as they are from different systems/database tables, but their contents match).</p>
  
  <p>In my example I have named the properties the same just to make it easier!</p>
  
  <p>I'd like to get a list of <code>Prefix+Number+Suffix</code> for accounts where there is a matching item in lookup (NOTE: Lookup can contain the same values multiple times - the rest of the properties in the objects are different)</p>
  
  <p>This is the code I am currently using, but it feels clunky.  Is there a cleaner, better way to acheive the same result?  I tried "Contains()" but wasn't sure how to restrict to all three properties.</p>
  
  <pre><code>    var accounts = new List&lt;Account&gt;{
          new Account{Prefix="001", Number="10101", Suffix="666"},
          new Account{Prefix="001", Number="10202", Suffix="777"},
          new Account{Prefix="001", Number="10303", Suffix="777"},
          new Account{Prefix="002", Number="20101", Suffix="666"},
          new Account{Prefix="002", Number="20101", Suffix="777"}
      };
  
      var lookup = new List&lt;Lookup&gt;{
          new Lookup{Prefix="001", Number="10101", Suffix="666"},
          new Lookup{Prefix="001", Number="10101", Suffix="666"},
          new Lookup{Prefix="002", Number="20101", Suffix="666"},
          new Lookup{Prefix="001", Number="10101", Suffix="666"},
      };
  
      var match = ((from a in accounts
                    select a)
                   .Intersect(from l in lookup
                              from a in accounts
                              where l.Prefix == a.Prefix &amp;&amp;
                              l.Number == a.Number &amp;&amp;
                              l.Suffix == a.Suffix
                              select a)
                              ).Select(a =&gt; string.Format("{0}{1}{2}", a.Prefix, a.Number, a.Suffix));
  </code></pre>