1
someDS.someDT.Where(x => x.Amount is not DBNull)
             .Sum(x => x.Amount);

According to the link How to compare DBNull value, the above code should be fine or is there any other way to handle the above scenario?

Community
  • 1
  • 1
SuicideSheep
  • 5,260
  • 19
  • 64
  • 117

2 Answers2

0

If your Amount is a nullable decimal then you can check null value of nullable decimal type as

someDS.someDT.Where(x => x.Amount.HasValue == true)
             .Sum(x => x.Amount);
Mostafiz
  • 7,243
  • 3
  • 28
  • 42
0
  someDS.someDT.Where(x => x.Amount != DBNull.Value)
         .Sum(x => x.Amount);
this.hart
  • 218
  • 2
  • 9