title: List of entities to datatable
body: <p>I have a list of entities which contain some of it fields as other entities.</p>
  
  <p>Eg.</p>
  
  <pre><code>MyEntity
  Int id
  ContactEntity Contact -&gt; contactId, Name etc…
  AddressEntity Address
  </code></pre>
  
  <p>So I have <code>List&lt; MyEntity&gt;</code> which needs to be converted to a data table. But from the sub entities I want only one field to be selected.</p>
  
  <p>Is it possible or do I have any other alternative.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>When I try <strong><em>CopyToDataTable()</em></strong> as ivowiblo describes it gives me following error </p>
  
  <pre><code> The type 'AnonymousType#1' cannot be used as type parameter 'T' in the generic type or
   method 'System.Data.DataTableExtensions.CopyToDataTable&lt;T&gt;(System.Collections.Generic.IEnumerable&lt;T&gt;)'.
   There is no implicit reference conversion from 'AnonymousType#1' to 'System.Data.DataRow'.
  </code></pre>