-1

in my database there is some row which is null and how can i use nullable type or how can i skip nullable row in linq? but i prefer to use nullable type rather than skip rows (see image)

enter image description here

jarlh
  • 42,561
  • 8
  • 45
  • 63

3 Answers3

1

You can't cast null to a non nullable type (decimal)

You should update your generic type to a nullable type like the below:

From

 let floatingPNL1 = b.Field<decimal>("FloatingPNL")

To

 let floatingPNL1 = b.Field<decimal?>("FloatingPNL")

Another option would be to use an ORM such as dapper, much easier to use and handles the object mapping for you.

Daniel
  • 976
  • 5
  • 14
0

Decimal? should be a nullable type

Billy8988
  • 29
  • 1
  • 4
0

Use Nullable<decimal> instead of decimal. Read more here

PWND
  • 409
  • 3
  • 11