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.
Decimal? should be a nullable type
Use Nullable<decimal>
instead of decimal
. Read more here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.