title: Displaying Custom Fields in LINQ to Entity Dynamic Select
body: <p>Let's say I have an entity <code>Container</code> with four properties: <code>ContainerID</code> (Integer), <code>ContainerNumber</code> (String), <code>Title</code> (String), and <code>Date</code> (Date).</p>
  
  <p>I have a second entity called <code>ContainerCustomFields</code> that has three properties: <code>CustomFieldID</code> (Integer), <code>ContainerID</code> (Integer and Foreign Key), <code>FieldName</code> (String), <code>FieldContent</code> (String). The <code>ContainerCustomFields</code> entity stores user-defined custom fields for the <code>Container</code> entity. The data looks like this:</p>
  
  <p>For Container:</p>
  
  <pre><code>Container
  ---------
  ID  |     Number     |     Title     |    Date      |
  =====================================================
  1   |      10000     |   1st Title   |   1/12/2017  |
  2   |      10543     |   2nd Title   |   1/31/2017  |
  3   |      10667     |   3rd Title   |   4/12/2016  |
  4   |      12889     |   4th Title   |   5/23/2012  |
  </code></pre>
  
  <p>For Custom Fields:</p>
  
  <pre><code>ID  |   ContainerID   |   FieldName   |    Content  |
  =====================================================
  1   |        1        |    Colour     |    Blue     |
  2   |        1        |    Height     |    5000     |
  3   |        1        |    Length     |    9100     |
  4   |        4        |    Colour     |    Gray     |
  </code></pre>
  
  <p>Is it possible to return the data so it looks like this:</p>
  
  <pre><code>Container
  ---------
  ID  |     Number     |     Title     |    Date      |   Colour   |  Height  |  Length  |  
  ====================================================================================
  1   |      10000     |   1st Title   |   1/12/2017  |    Blue    |   5000   |   9100   |
  2   |      10543     |   2nd Title   |   1/31/2017  |            |          |          |
  3   |      10667     |   3rd Title   |   4/12/2016  |            |          |          |
  4   |      12889     |   4th Title   |   5/23/2012  |    Gray    |          |          |
  </code></pre>
  
  <p>I'm able to get a list of the custom fields and their values for each container as well as select the columns that I want from the entity using a select statement. How do I combine these two statements?</p>
  
  <pre><code>For Each customField In _db.ContainerCustomFields
    .Where(Function(cf) cf.ContainerID = newBox.ContainerID)
  
  returnContainers.Select(Function(c) New With 
    {.ContainerID = c.ContainerID, 
     .Number = c.ContainerNumber,
     .Title = c.Title,
     .Date = c.Date })
  </code></pre>
  
  <p>I'm using Web API 2 to return this as an anonymous type for my web application. </p>