Anirban Ghosh
Anirban Ghosh

Reputation: 125

comparing Decimal(9,3) column value in Linq

I have a column pointsAwarded decimal(9,3) and I have the following LInq

db.TableName.Select(x=>x.pointsAwarded >0)

The fact is that it is not filtering the data and returning me the whole result set. How to compare it? I tried with x.pointsAwarded.value>0 and x.pointsAwarded.value>0.000 and

x.pointsAwarded > (Decimal?)0

but with no luck. Pls help

Upvotes: 0

Views: 272

Answers (1)

Jens Kloster
Jens Kloster

Reputation: 11277

Try using a Where instead of a Select

db.TableName.Where(x=>x.pointsAwarded > 0)

UPDATE:
This answer has been given more credit than it previously deserved, so I will elaburete a little

The Where statement acts as the filter. It determins whitch elements the returned list should contain.
The Select statement is the projection of the elements. Given a list of elements, how would you like them presented.

Upvotes: 4

Related Questions