What's the easiest way of spinning these (erroneous) lines?
bool? result = dr["result"] == DBNull.Value ? null : Convert.ToInt32(dr["result"])
dr["result"] = result ?? DBNull.Value
Both don't compile.
I'm while using MySql connector also it does not allow me to set, for instance,
dr["result"] = null; that is things i first attempted.
Can there be an more appropriate .Internet data type for representing a MySql nullable
dr["Hello"] = (object)result ?? DBNull.Value; bool? result = dr["result"] == DBNull.Value ? null : (bool?)(Convert.ToInt32(dr["result"]) != 0);
The main reason your suggestion doesn't compile is the fact that both options from the ternary operator
?: must have a similar type.
DBNull.Value clearly isn't the same type like a
bool?. Casting the
bool? for an
object however means they are both same type. Similar rules apply around the second row.
if you work with SP or SQL Quries you'll be able to use isNULL() purpose of SQL to deal with NULL handling by utilizing SQL.....