how can i loop through all of the columns of the OracleDataReader
You should be able to do something like this:
Dictionary<string, string> fields = new Dictionary<string, string>();OracleDataReader reader = command.ExecuteReader();if( reader.HasRows ){ for( int index = 0; index < reader.FieldCount; index ++ ) { fields[ reader.GetName( index ) ] = reader.GetString( index ); } }
GetSchemaTable will return a lot of information about the columns, including their name but also size, type, etc.
I presume you want the key of the dictionary to be the column name, and the value to be the row value. If so, this should work:
var dict = reader.GetSchemaTable().Rows.OfType<DataRow>().Select( r => r["ColumnName"].ToString()).ToDictionary( cn => cn, cn => reader[cn].ToString());
You could also use GetValues() to get the number of columns, and call GetName(int) for each.