views:

27

answers:

2

I have a linq query, that gets data from a table in a DataContext object. One of the columns in this table has a Datatype of float. I would like to get the total of that specific column. How could I go about doing this?

+2  A: 
var sum = (from row in table
           select row.value).Sum();
brickner
+2  A: 
var sum = context.Foos.Sum(foo => foo.Bar);

... assuming an entity type named Foo with a numerical column named Bar.

Daniel Brückner