Inquiry to bring users in.
public IEnumerable PopulaTabelaUsuario()
{
var banco = new DbBancoContext();
var listaUsuarios = (from l in banco.USUARIOS_PROCESSO
select new{ l.ID_USUARIO, l.NOME_USUARIO }).ToList();
return listaUsuarios;
}
My controller.
public ActionResult AreaPrincipal()
{
var lista = new ConsultasNecessarias();
var usuarios = lista.PopulaTabelaUsuario();
//var r = new DbBancoContext();
//var s = r.USUARIOS_PROCESSO.Select(m=>m.NOME_USUARIO).ToList();
return View(usuarios);
}
My View.
@model IEnumerable<ControleVisita.Models.USUARIOS_PROCESSO>
@{
ViewBag.Title = "Área Principal";
}
@section Menu{
}
<table class="table table-hover">
<thead>
<tr>
<th>Id Usuário</th>
<th>Nome</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => @item.ID_USUARIO)</td>
<td>@Html.DisplayFor(modelItem => @item.NOME_USUARIO)</td>
</tr>
}
</tbody>
</table>
But when I run it displays the following error.
The template item entered in the dictionary is from type System.Collections.Generic.List
1[<>f__AnonymousType4
2 [System.Int32, System.String]] ', but this dictionary requires an item of type 'System.Collections.Generic.IEnumerable'1 [ControlVisit.Models.USER_PROCESSUS]'.