Esempio n. 1
0
        /// <summary>
        /// Simple helper method that creates a correct IndexRowset and returns
        /// it's PyDataType representation, ready to be sent to the EVE Online client
        ///
        /// </summary>
        /// <param name="reader">The MySqlDataReader to read the data from</param>
        /// <returns></returns>
        public static IndexRowset FromMySqlDataReader(MySqlDataReader reader, int indexField)
        {
            string indexFieldName = reader.GetName(indexField);

            PyList headers = new PyList(reader.FieldCount);

            for (int i = 0; i < reader.FieldCount; i++)
            {
                headers[i] = reader.GetName(i);
            }

            IndexRowset rowset = new IndexRowset(indexFieldName, headers);

            while (reader.Read() == true)
            {
                PyList row = new PyList(reader.FieldCount);

                for (int i = 0; i < row.Count; i++)
                {
                    row[i] = Utils.ObjectFromColumn(reader, i);
                }

                rowset.AddRow(reader.GetInt32(indexField), row);
            }

            return(rowset);
        }
Esempio n. 2
0
        /// <summary>
        /// Simple helper method that creates a correct IndexRowset and returns
        /// it's PyDataType representation, ready to be sent to the EVE Online client
        ///
        /// </summary>
        /// <param name="connection">The connection used</param>
        /// <param name="reader">The MySqlDataReader to read the data from</param>
        /// <param name="indexField">The field to use as index for the rowset</param>
        /// <returns></returns>
        public static IndexRowset FromMySqlDataReader(IDatabaseConnection connection, MySqlDataReader reader, int indexField)
        {
            string indexFieldName = reader.GetName(indexField);

            connection.GetDatabaseHeaders(reader, out PyList <PyString> headers, out FieldType[] fieldTypes);

            IndexRowset rowset = new IndexRowset(indexFieldName, headers);

            while (reader.Read() == true)
            {
                PyList row = new PyList(reader.FieldCount);

                for (int i = 0; i < row.Count; i++)
                {
                    row[i] = IDatabaseConnection.ObjectFromColumn(reader, fieldTypes[i], i);
                }

                rowset.AddRow(reader.GetInt32(indexField), row);
            }

            return(rowset);
        }