Query Datatable
<p>I have a DataTable that looks like this:</p>

<pre><code>Id Value
123 4.0
123 5.0
234 1.0
345 2.0
345 3.0
</code></pre>

<p>I want to end up with (probably a new DataTable) that contains the sum of
values grouped by Id like this:</p>

<pre><code>Id SumOfValue
123 9.0
234 1.0
345 5.0
</code></pre>

<p>Here is my code,</p>

<pre><code>var query = from row in dTable.AsEnumerable()
group row by row.Field&lt;double&gt;("ITEM_NO") into grp
orderby grp.Key
select new
{
    ITEM_NO = grp.Key,
    sum = grp.Sum(r = r.Field&lt;double&gt;("ITEM_STOCK"))
};
</code></pre>

<p>I am getting an error that <code>r is undefined</code>, also I am not able to add these values in a new datatable.</p>

<p>Does anyone know how to write this?</p>

<p>Thanks.</p>
