title: Error when Copying Query from linq to Datatable
body: <p>I just started working on a project that requires <code>Linq to Sql</code>, and I have been able to make queries and retrieve data. But right now I need to fill a <code>DataTable</code> with the data I am retrieving.</p>
  
  <p>My first code was the following:</p>
  
  <pre><code>MyDatabase db = new MyDatabase();
  var query = from cust in db.Customers
              where cust.CustomerName != "Dante"
              orderby cust.CustomerName
              select new { Name = cust.CustomerName }; 
  </code></pre>
  
  <p>So, since I needed to copy the content of my query to a <code>Datatable</code> I tried <a href="https://stackoverflow.com/questions/16/filling-a-dataset-or-datatable-from-a-linq-query-result-set">this</a>:</p>
  
  <pre><code> IEnumerable&lt;DataRow&gt; query =
      from order in orders.AsEnumerable()
      where order.Field&lt;DateTime&gt;("OrderDate") &gt; new DateTime(2001, 8, 1)
      select order;
  
  // Create a table from the query.
  DataTable boundTable = query.CopyToDataTable&lt;DataRow&gt;();
  </code></pre>
  
  <p>Then, my code looks like this:</p>
  
  <pre><code>IEnumerable&lt;DataRow&gt; myQuery = from cust in db.Customers.AsEnumerable()
                      where cust.Name != "Dante"
                      orderby cust.Name
                      select new { Name = cust.Name };
  
  DataTable myDataTable = myQuery.CopyToDataTable&lt;DataRow&gt;();
  </code></pre>
  
  <p>But with this code the compiler raises and error:</p>
  
  <p><code>Cannot implicitly convert type 'System.Collections.Generic.IEnumerable&lt;AnonymousType#1&gt;' to 'System.Collections.Generic.IEnumerable&lt;System.Data.DataRow&gt;</code></p>
  
  <p>The error is raised at the <code>select</code> word.</p>
  
  <p>So, <strong>What am I doing wrong?? What can I do in order to avoid this conversion issue?</strong></p>
  
  <p>Hope someone can help me, thanks in advance.</p>