/// <summary>
        /// Executes a command and returns the result
        /// </summary>
        /// <param name="command">The command to execute</param>
        /// <param name="connection">The connection to use</param>
        /// <returns></returns>
        public virtual QueryData ExecuteCommandQuery(IDbCommand command, IDataConnection connection)
        {
            QueryData toReturn = new QueryData();
            IDbConnection conn = connection.GetConnection();

            if (conn.State != ConnectionState.Open)
                conn.Open();
            if (connection.IsTransactional)
                command.Transaction = connection.GetTransaction;
            command.Connection = conn;
            command.CommandTimeout = 10000;
            IDataReader reader;
            try
            {
                FireEvent(command, connection);

                using (reader = command.ExecuteReader())
                {
                    if (!_mappings.ContainsKey(command.CommandText))
                    {
                        _mappings[command.CommandText] = new Dictionary<string, int>();
                        DataTable schema = reader.GetSchemaTable();

                        if (schema != null)
                        {
                            for (int i = 0; i < schema.Rows.Count; i++)
                            {
                                _mappings[command.CommandText].Add(schema.Rows[i]["ColumnName"].ToString().ToUpper(), i);
                            }
                        }
                    }

                    toReturn.SetFieldMappings(_mappings[command.CommandText]);

                    while (reader.Read())
                    {
                        object[] values = new object[reader.FieldCount];
                        reader.GetValues(values);
                        toReturn.AddRowData(values);
                    }
                }
            }
            catch (Exception e)
            {
                //throw new QueryException(e, command);
                throw e;
            }
            finally
            {
                if (!connection.IsTransactional)
                    conn.Close();
            }

            toReturn.QuerySuccessful = true;


            return toReturn;
        }