1
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" }
]
});
});
that’s the table
And I need to win in mega sena hehehehe. You really need those objects as described in
columns
? And if you need to, why are you populating a completely different one? What exactly is your question?– Leandro Angelo
use line["nomedacoluna"]
– Marco Vinicius Soares Dalalba