Anjana
Anjana

Reputation: 1453

How to perfom a mathematical operation in LINQ

I need to form a Select query in LINQ for a table with fields A, B, C. I need to get the values A and A - B.

Upvotes: 0

Views: 1758

Answers (2)

andrews_nz
andrews_nz

Reputation: 185

Try Select(r = new { r.A, Difference = r.A - r.B })

Upvotes: 1

Garrett Vlieger
Garrett Vlieger

Reputation: 9494

Try this:

 from t in yourTable
 select t.A, t.A - t.B

Upvotes: 2

Related Questions