how do I sum on Test using LinqToDataset

T

Tony

DataTable dt = new DataTable();
dt.Columns.Add("Test", typeof(int));
dt.Rows.Add(10);
dt.Rows.Add(20);
dt.Rows.Add(30);

int linqSum = (from DataRow dr in dt.AsEnumerable()
select dr["Test"]).Sum();

//Tony
 
T

Tony

"Tony" wrote in message
DataTable dt = new DataTable();
dt.Columns.Add("Test", typeof(int));
dt.Rows.Add(10);
dt.Rows.Add(20);
dt.Rows.Add(30);

int linqSum = (from DataRow dr in dt.AsEnumerable()
select dr["Test"]).Sum();

//Tony

I fount it
sumFgTimeGtidLoopnr = dsFgodsdagTimeWrk.Tables[0].AsEnumerable().Sum(x =>
x.Field<int>("Test"));

//Tony
 

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