User-1380038293 posted
Hi,
I am LINQ querrying against a datatable. However, I am unsuccessfull with catching null values. Here is my code that is giving me the following error.
Dim query = From line In dtCS.AsEnumerable()
Where line.Field(Of Integer)("creditorid") = id
Select New With {.minperc = IIf(IsDBNull(line.Field(Of Double)("minimumpercent")), 0, line.Field(Of Double)("minimumpercent")),
.minamt = line.Field(Of Object)("minimumamount"),
.perof = line.Field(Of Integer)("percentof")}
I am checking to see if minperc is null. However to check that it still is trying to convert the value to double. Cant figure out a way around it.
Here is the error:
Cannot cast DBNull.Value to type 'System.Double'. Please use a nullable type.