Is there a way in C# to determine if a database field is nullable in a relatively database/platform agnostic fashion? In other words, within Oracle I could do something like this:
select column_name, nullable
from all_tab_columns
where table_name = :TABLE
But that approach is tethered to the Oracle, and I'd have to come up with an equivalent for other platforms.
What I was hoping for was a means to do this through the data providers. I was able to extract the datatypes using something similar to this:
AseCommand cmd = new AseCommand(sql, conn);
AseDataReader reader = cmd.ExecuteReader();
for (int i = 0; i < reader.FieldCount; i++)
{
string name = reader.GetName(i);
string dbTypeName = reader.GetDataTypeName(i);
Type dbType = reader.GetFieldType(i);
}
In this example it's Sybase, but the approach has been polymorphic across other platforms, at least for the DBs I've been using.
The only thing I'm missing is whether or not the field is nullable.