title: Multiple Linq (Extension Method) Joins With Anonymous Types
body: <p>In C#, I'm attempting to do multiple extension-method joins, in which the second join is with an enumerable of an anonymous type produced by the first join:</p>
  
  <pre><code>List&lt;Contact&gt; filteredContactList = GetFullContacts()
      .Join(GetContactCompanyRoles()
          , ct =&gt; ct.IdContact
          , ctCmpRole =&gt; ctCmpRole.IdContact
          , (ct, ctCmpRole) =&gt; new { Contact = ct, ContactType = ctCmpRole.ContactType })
      .Join(GetContactRoles()
          , ctf =&gt; new { ctf.Contact.IdContact, ctf.ContactType }
          , ctRole =&gt; new { ctRole.ContactId, ctRole.ContactType }
          , (ctf, ctRole) =&gt; new { Contact = ctf.Contact, PrimaryInd = ctRole.IsPrimary})
      .Select(rec =&gt; rec.Contact)
      .ToList();
  </code></pre>
  
  <p>ct and ctf.Contact is of Type Contact.</p>
  
  <p>I am, however, getting the following error when attempting to compile:</p>
  
  <blockquote>
    <p>The type arguments for method 'System.Linq.Enumerable.Join...' cannot be inferred from the usage. Try specifying the type argument explicitly.</p>
  </blockquote>
  
  <p>Is there a way to get around this error without having to create an actual class for the anonymous type from the first join? Are there other options that I am not considering?</p>