Krummelz
Krummelz

Reputation: 1046

Total of float column in linq query

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?

Upvotes: 0

Views: 1341

Answers (2)

Daniel Brückner
Daniel Brückner

Reputation: 59685

var sum = context.Foos.Sum(foo => foo.Bar);

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

Upvotes: 3

brickner
brickner

Reputation: 6585

var sum = (from row in table
           select row.value).Sum();

Upvotes: 2

Related Questions