select sum from column

J

Jeff

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?
 
M

Marc Gravell

.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top