コード例 #1
0
        public string getTop10Fabricantes()
        {
            string query = "SELECT NOME_PAIS_FABRIC, COUNT(NOME_PAIS_FABRIC) FROM anvisa_dados " +
                           " GROUP BY NOME_PAIS_FABRIC ORDER BY COUNT(NOME_PAIS_FABRIC) DESC limit 10 ";

            MySqlConnection connection = new MySqlConnection(config);
            MySqlCommand    command    = new MySqlCommand(query, connection);

            connection.Open();
            MySqlDataReader Reader = command.ExecuteReader();

            var json = new List <FabricanteJSON>();

            while (Reader.Read())
            {
                FabricanteJSON obj = new FabricanteJSON();
                obj.Nome  = Reader[0].ToString();
                obj.Count = Reader[1].ToString();

                json.Add(obj);
            }
            connection.Close();
            string jsonstring = JsonConvert.SerializeObject(json, Formatting.Indented);

            return(jsonstring);
        }
コード例 #2
0
        public string getRiscosPorVigencia()
        {
            string query = " SELECT VALIDADE_REGISTRO_CADASTRO, CLASSE_RISCO, COUNT(CLASSE_RISCO)" +
                           "FROM anvisa_dados WHERE VALIDADE_REGISTRO_CADASTRO= 'VIGENTE' GROUP BY CLASSE_RISCO" +
                           "ORDER BY COUNT(CLASSE_RISCO)DESC  ";

            MySqlConnection connection = new MySqlConnection(config);
            MySqlCommand    command    = new MySqlCommand(query, connection);

            connection.Open();
            MySqlDataReader Reader = command.ExecuteReader();

            var json = new List <FabricanteJSON>();

            while (Reader.Read())
            {
                FabricanteJSON obj = new FabricanteJSON();
                obj.Nome  = Reader[0].ToString();
                obj.Count = Reader[1].ToString();

                json.Add(obj);
            }
            connection.Close();
            string jsonstring = JsonConvert.SerializeObject(json, Formatting.Indented);

            return(jsonstring);
        }