Fiz esse html dentro do meu cshtml. Fui fazer um foreach e deu erro no foreach e também não reconheceu modelItem. Na pasta Models estão meu edmx, logo T_PDV é uma entidade do BD mapeada nesse edmx.
@model SuporteTecnico.Models.T_PDV
@{
ViewBag.Title = "Formulário";
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Pesquisa</title>
</head>
<body>
<table>
<tr>
<th>@Html.DisplayNameFor(model => model.RazaoSocial)</th>
<th>@Html.DisplayNameFor(model => model.CNPJ)</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>@Html.DisplayFor(modelItem => item.RazaoSocial)</td>
<td>@Html.DisplayFor(modelItem => item.CNPJ)</td>
</tr>
}
</table>
</body>
</html>
Abaixo os erros respectivamente no foreach e no DisplayFor
foreach statement cannot operate on variables of type 'V99SuporteTecnico.Models.T_PDV' because 'V99SuporteTecnico.Models.T_PDV' does not contain a public definition for 'GetEnumerator'
The type arguments for method 'System.Web.Mvc.Html.DisplayExtensions.DisplayFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>)'
cannot be inferred from the usage. Try specifying the type arguments explicitly.