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