hey
.NET 2.0
My project have a DataSet. In this DataSet there is a DataTable, which has a
column I want to calculate the sum on... In sql this would be done like this
: select sum(column1) from table1... but AFAIK I cannot use sql statmetns
against a DataTable...
So I've been thinking about use DataTable.Select but think that wouldn't be
a good solution because in the Select method I need to provide som filter
expression, but I don't want to filter out any rows...
any suggestions?
Jeff - 15 Jan 2008 09:25 GMT
Okay, I've solved it... I used DataTable.Compute()
> hey
>
[quoted text clipped - 10 lines]
>
> any suggestions?
Marc Gravell - 15 Jan 2008 12:29 GMT
> .NET 2.0
It doesn't apply (because of your 2.0 statement), but for the list's
benefit: LINQ provides an alternative for this, using (simply)
theTable.Sum(x=>x.Column1);
Just for reference,
Marc
Ivica Muruzovic - 16 Jan 2008 08:09 GMT
use
DataTable.Compute("sum(column1)","")
>hey
>
[quoted text clipped - 10 lines]
>
>any suggestions?