Пример #1
0
        /// <summary>
        /// 获取排行榜信息
        /// </summary>
        /// <returns></returns>
        public static RankListDto GetRankListDto()
        {
            MySqlCommand    cmd    = new MySqlCommand("select name,coin from user order by coin desc", sqlConnection);
            MySqlDataReader reader = cmd.ExecuteReader();

            rankListDto.Clear(); // 先清空排行榜信息
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    RankItemDto dto = new RankItemDto(reader.GetString("name"), reader.GetInt32("coin"));
                    rankListDto.Add(dto);
                }
                reader.Close();
                return(rankListDto);
            }
            reader.Close();
            return(null);
        }
Пример #2
0
        /// <summary>
        /// 获取排行榜信息
        /// </summary>
        /// <returns></returns>
        public static RankListDto GetRankListDto()
        {
            MySqlCommand    cmd    = new MySqlCommand("select UserName,Coin from userinfo order by Coin desc", sqlConcect);
            MySqlDataReader reader = cmd.ExecuteReader();

            rankListDto.Clear();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    RankItemDto dto = new RankItemDto(reader.GetString("UserName"), reader.GetInt32("Coin"));
                    rankListDto.Add(dto);
                }
                reader.Close();
                return(rankListDto);
            }
            reader.Close();
            return(null);
        }