title: What is the cheapest way to execute a LINQ-Query immediately
body: <p>This question came into my mind while generating sample data for a SO-answer.
  I don't like the verbose way of adding DataRows one by one via <code>Tbl.Rows.Add</code>, so i've created this pseudo LINQ query that does nothing but adding rows implicitely:</p>
  
  <pre><code>Private Function GetData() As DataTable
      Dim years = {"2010/2009", "2009/2008", "2008/2007", "2007/2006", "2006/2005", "2005/2004", "2004/2003"}
      Dim tbl = New DataTable
      tbl.Columns.Add(New DataColumn("Year"))
      ' adds DataRows to the DataTable, need Count to execute the query '
      Dim c = (From y In years Select tbl.Rows.Add(y)).Count 
      Return tbl
  End Function
  </code></pre>
  
  <p>As you can see i don't need the result of the query at all, it's only purpose is to iterate and call <code>DataTable.Rows.Add</code>. So the result is already available in the DataTable itself and not needed from the query.</p>
  
  <p>Admittedly this question is somewhat hyphotetical because there would not be a big difference in using f.e. <code>ToList</code> and normally a query's purpose is to return something.</p>
  
  <p>But anyway, what's the cheapest way(in terms of memory consumption, execution time) to execute a LINQ query when only the execution and not the result matters?</p>
  
  <p><strong>Edit</strong>: Ok, thisquestion was a quick-shot and a chicken-and-egg problem. I wanted to reduce 20 lines of code to a single line but noticed that i need some kind of DataSource for the LINQ-Query. Therefor i've created the Array. But at this point i could have simply used a for-each loop as well to add the DataRows. </p>
  
  <p><strong>Conclusion</strong>: Use a LINQ-Query for what it's for: a <em>query</em>. Then this question is pointless since there is no <em>cheapest</em> way but only that which returns the correct result.</p>