I'm making my first forays into Accessing Oracle from C#. I've discovered that that Oracle doesn't like VarChar parameters to have value of null (C#). I would have hoped that there would be some implicit conversion, but I appreciate the difference.
So I need to trap these null values and supply DBNull.Value instead, surely? The most obvious method was to use the coalesce operator (??):
param myParm = myObject.MyProperty ?? DBNull.Value;
Except it doesn't accept a value of System.DBNull... so I have to use:
param myParm = myObject.MyProperty ?? DBNull.Value.ToString();
...which is surely the same as:
param myParm = myObject.MyProperty ?? String.Empty;
..which also works.
But I always understood that according to ANSI SQL rules, an empty string ("") != a NULL value... yet it appears to be in Oracle.
Anyway, my question is, what is the best, practical or theoretical, way to handle the case of null string values? Is there a slick alternative that I haven't identified? Or is this just another idiosyncrasy of Oracle that we just accept?