title: Extract a new object by matching a common property between an IQueryable<T> and a Dictionary<String, String>
body: <p>I have an scenario where I need to generate a new <code>List&lt;my_custom_object&gt;</code> by extracting, on the basis of a common column, matched properties between an <code>IQueryable&lt;T&gt;</code> and a <code>Dictionary&lt;String, String&gt;</code>.</p>
  
  <p>Here is my Dictionary:</p>
  
  <pre><code>DirectoryProfilePropertiesCollection = (Dictionary&lt;String, String&gt;)ApiMethods.GetProfileProperties(OrganizationIdentifier, DirectoryIdentifier, DirectoryUserName, DirectoryUserPassword);
  </code></pre>
  
  <p>This returns following information:</p>
  
  <pre><code>Key: samAccountName, Value: hgulzar 
  Key: sn,             Value: Hassan
  Key: lastname,       Value: Gulzar
  </code></pre>
  
  <p>The key here is called Attribute Name.</p>
  
  <p>I also have an <code>IQueryable</code>:</p>
  
  <pre><code>var DirectoryMappingsCollection = repository.GetQuery&lt;OrganizationDirectoryMapping&gt;(where =&gt; where.OrganizationDirectory.Organization.OrganizationUnit.UnitIdentifier == OrganizationIdentifier &amp;&amp; where.OrganizationDirectory.DirectoryIdentifier == DirectoryIdentifier);
  </code></pre>
  
  <p>The <code>OrganizationDirectoryMapping</code> entity has a property called <code>DirectoryAttribute</code></p>
  
  <p>Both collections have data when I'm to match them. The <code>DirectoryProfilePropertiesCollection</code>'s pair has <code>AttributeName</code> and <code>AttributeValue</code>. The <code>DirectoryMappingsCollection</code>'s entity, <code>OrganizationDirectoryMapping</code>, has <code>AttributeName</code> and <code>DetailName</code></p>
  
  <p>I need to get a custom class object that represents: <code>DetailName</code>, <code>DirectoryAttribute</code>, and <code>AttributeValue</code></p>
  
  <p>Been trying a few queries but got stuck when I got the exception:</p>
  
  <pre><code>Unable to create a constant value of type 'System.Collections.Generic.KeyValuePair`2'. Only primitive types or enumeration types are supported in this context.
  </code></pre>
  
  <p>The question <a href="https://stackoverflow.com/q/11431244/481656">LinQ nested collection query</a> made a bit of sense of the exception but I'm still stuck.</p>
  
  <p>Regards.</p>
  
  <p>What I've tried so far:</p>
  
  <pre><code>combinedCol = (from mapCol in DirectoryMappingsCollection
                                                  join propCol in DirectoryProfilePropertiesCollection
                                                  on mapCol.DirectoryAttribute equals propCol.Key
                                                  select new CombinedMappingDataCollection
                                                  {
                                                      DetailName = mapCol.DetailRequirement.DetailName,
                                                      AttributeName = propCol.Key,
                                                      AttributeValue = propCol.Value
                                                  }).ToList();
  </code></pre>