I need the name of the package to appear in the history table but the package_id is appearing

0
public List<HistoricoViagem> ObterTodosParaJSON(string start, string length)
    {
        List<HistoricoViagem> historicoViagens = new List<HistoricoViagem>();
        SqlCommand command = new Conexao().ObterConexao();
        command.CommandText = @"SELECT hv.id, p.id, hv.id_pacote, hv.data_, p.nome FROM historico_de_viagens hv
        INNER JOIN pacotes p ON (p.id_pacote = hv.id_pacote)";
        DataTable tabela = new DataTable();
        tabela.Load(command.ExecuteReader());
        foreach (DataRow linha in tabela.Rows)
        {
            HistoricoViagem historicoViagem = new HistoricoViagem()
            {
                Id = Convert.ToInt32(linha[0].ToString()),
                IdPacote = Convert.ToInt32(linha[2].ToString()),
                Data = Convert.ToDateTime(linha[3].ToString()),
                Pacote = new Pacote()
                {
                    Id = Convert.ToInt32(linha[1].ToString()),
                    Nome = linha[4].ToString()
                }


            };
            historicoViagens.Add(historicoViagem);
        }
        return historicoViagens;
    }

This is the code where I need to bring the package name

$(function () {
 $('#guia-tabela').DataTable({
    "processing": true,
    "serverSide": true,
    "ajax": "/Guia/ObterTodosPorJSON",
    "columns": [
        { "data": "Id" },
        { "data": "Nome" },
        { "data": "Sobrenome" },            
        { "data": "Cpf" },
        { "data": "Rank" }
    ]
 });
});

this is the table

    
asked by anonymous 29.08.2018 / 01:13

1 answer

0

Place Alias in your select.

SELECT hv.id as "id do hv", p.id as "id do p", hv.id_pacote as "id do pacote",
       hv.data as "data", p.nome as "nome" 
FROM historico_de_viagens hv INNER JOIN pacotes p ON (p.id_pacote = hv.id_pacote)
    
29.08.2018 / 03:35