public override void ReadValue(int i) { if (m_myReader != null) { var type = m_myReader.GetFieldNpgsqlDbType(i); if ((type & NpgsqlTypes.NpgsqlDbType.Array) != 0) { object obj = m_myReader.GetValue(i); if (obj == DBNull.Value) { this.SetNull(); return; } var ar = (Array)m_myReader.GetValue(i); var sb = new StringBuilder(); int[] indices = new int[ar.Rank]; WriteArrayDimension(sb, ar, indices, 0); this.ReadFrom(sb.ToString()); return; } } base.ReadValue(i); }
public Queue <Hashtable> Select(string sSQL, Dictionary <string, object> ahParams) { Queue <Hashtable> aqRetVal = new Queue <Hashtable>(); Hashtable ahRow = null; sSQL = sSQL.Replace('`', '"'); lock (_oSyncRoot) { if (_bTransactionRollback) { return(new Queue <Hashtable>()); } Connect(); _sLastQuery = sSQL; NpgsqlCommand cCommand = new NpgsqlCommand(sSQL, _cConnection); try { CommandParametersFill(cCommand, ahParams); NpgsqlDataReader cDataReader = cCommand.ExecuteReader(); string sKey = ""; while (cDataReader.Read()) { ahRow = new Hashtable(cDataReader.FieldCount); for (int nFieldIndx = 0; cDataReader.FieldCount > nFieldIndx; nFieldIndx++) { sKey = cDataReader.GetName(nFieldIndx); if (1 == cDataReader.FieldCount && "connectiontest" == sKey) { return(null); } if (cDataReader.IsDBNull(nFieldIndx)) { ahRow[sKey] = null; continue; } switch (cDataReader.GetFieldNpgsqlDbType(nFieldIndx)) { case NpgsqlTypes.NpgsqlDbType.Timestamp: case NpgsqlTypes.NpgsqlDbType.TimestampTZ: ahRow[sKey] = cDataReader.GetDateTime(nFieldIndx); break; case NpgsqlTypes.NpgsqlDbType.Bytea: ahRow[sKey] = (byte[])cDataReader[nFieldIndx]; break; default: ahRow[sKey] = cDataReader[nFieldIndx]; break; } } aqRetVal.Enqueue(ahRow); } } finally { try { if (null == _cTransaction) { _cConnection.Close(); } } catch { } } return(aqRetVal); } }