I have an application written in C# using VS 2012 that needs to determine the type of data contained in the result of a PostgreSQL query at run time. For example, a command object is set up to execute "select * from my_table". For each field in the returned reader, a line is written into a file, which would end up looking like this:
my_table.field1 is an integer
my_table.field2 is a real
my_table.field3 is a timestamp
The problem comes with fields that contain intervals. Using both the latest PostgreSQL ODBC driver and NPGSQL, a field that contains an interval is read as though it contained text. I can use the TimeSpan.Parse() method to see if the data in the field can be mapped to a TimeSpan, but that feels like a violation of a basic database principle to me. Is there a way for a C# application to directly determine that a field contained in a DataReader object is of type interval?