public List <Ranking> Listar() { try { cmd.Connection = conexao.Conectar(); cmd.CommandText = "EXEC RankingCurtida"; SqlDataReader dados = cmd.ExecuteReader(); List <Ranking> rank = new List <Ranking>(); while (dados.Read()) { rank.Add( new Ranking() { Posicao = Convert.ToInt32(dados.GetValue(0)), IdUsuario = Convert.ToInt32(dados.GetValue(1)), Pontos = Convert.ToInt32(dados.GetValue(2)) } ); } conexao.Desconectar(); return(rank); } catch (Exception ex) { throw new Exception(ex.Message); } }