0
While executing my foreach, he is repeating my first result in sql.
For example:
- In doing
select * from tbNomehe returnsGabriel, Rafael When executing the
sqlquery, he listGabriel, GabrielList<TbListaNome> lstViewModel= new List<TbListaNome>(); var lista = db.TbListaNome.SqlQuery.("Select * from TbNome").ToList<TbListaNome>(); foreach(var item in lista) { NomesViewModel viewModel = new NomesViewModel(); viewModel .nome = item.nome; lstViewModel.add(viewModel); } return View(viewModel);
TbListaNome is db set
NomesViewModel is my model view
Are you selecting the correct table? Your select is selecting the Tbname table. Your template, already named as Tblistaname
– Lucas
Fix here but keep repeating and the weirdest it returns the same amount of my select and replaced by the first record
– gabriel