Abhilash JA Abhilash JA - 21 days ago 5
C# Question

error - Linq query returns true or false if Null value in the row

The DataTable 'IsActive1' field return empty value.

enter image description here

I have written Linq query,

enter image description here

But, It occured error. How can I solve this?

Answer

Write the definition of the column as bool? if you expect to be null.

myRow.Field<bool?>("IsActive1") == null ? true: myRow.Field<bool?>("Active1") ...
Comments