title: General method to select first row from every group in DataTable, give a List of grouping column
body: <p>I can use this code to get every first row from each group (group by ID) from DataTable:</p>
  
  <pre><code>dt = dt.AsEnumerable().GroupBy(r =&gt; r.Field&lt;int&gt;("ID")).Select(g =&gt; g.First()).CopyToDataTable();
  </code></pre>
  
  <p>But it group only ID and I have to hardcode it myself. </p>
  
  <p>I wonder if there is general method, that put in a list of column name to group. </p>
  
  <pre><code>public DataTable GetFirstFromEachGroupBy(List&lt;string&gt; GroupByColumns)
  {
    dt = dt.AsEnumerable().GroupBy(GroupByColumns).Select(g =&gt; g.First()).CopyToDataTable();
  }
  </code></pre>