title: Save linq query as data table
body: <p>In c# MVC, I need to get the following "result" (var) in the data table.</p>
  
  <pre><code>var allCompanies = objentity.ExecuteFunction&lt;SearchAvailEmployees_Result&gt;("SearchAvailEmployees", lstParam.ToArray())
                              .ToList();
  
  var result = from c in allCompanies select new[] { 
                              c.LastName, 
                              c.FirstName, 
                              c.Phone, 
                              c.City, 
                              c.PositionApplied, 
                              c.Status, 
                              Convert.ToString(c.CallDate.Value.ToShortDateString()), 
                              Convert.ToString(c.CellOrPager), 
                              c.Gender 
                          };
  </code></pre>
  
  <p>I tried the following code but it won't works. It gives the error as </p>
  
  <blockquote>
    <p>"Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?)"</p>
  </blockquote>
  
  <pre><code>IEnumerable&lt;DataRow&gt; query = from c in allCompanies select new[] { 
                                              c.LastName, 
                                              c.FirstName, 
                                              c.Phone, 
                                              c.City, 
                                              c.PositionApplied, 
                                              c.Status, 
                                              Convert.ToString(c.CallDate.Value.ToShortDateString()), 
                                              Convert.ToString(c.CellOrPager), 
                                              c.Gender 
                                          };
  
  DataTable boundTable = query.CopyToDataTable&lt;DataRow&gt;();
  </code></pre>
  
  <p>Any alternate solution to save the linq query result in data table?</p>