First, you create a concrete class "InfoViewModel" for example that has properties for your fields in the select statement: CompanyName, CompanyID, TickerSymbol, etc,
public class InfoViewModel<br />
{<br />
public string CompanyName { get; set; }<br />
public string CompanyID { get; set; }<br />
etc...<br />
}
then create a List<infoviewmodel> from your query in the PageModel
public List<InfoViewModel> Info= new List<InfoViewModel>();
and then create a foreach loop after the select statement to store the query result in the list you created, in order not to have a conflict regarding the anonymous type error that you will face.
<br />
select new <br />
{<br />
CompanyName = c.companyName,<br />
CompanyID = c.companyId,<br />
etc...<br />
}).ToList();<br />
<br />
<br />
foreach (var item in q)<br />
{<br />
InfoViewModel info = new InfoViewModel();<br />
info.CompanyName = item.CompanyName ;<br />
info.CompanyID = item.CompanyID ;<br />
etc...<br />
Info.Add(info);<br />
}<br />
then in the .cshtml ViewModel:
<tbody><br />
@foreach (var item in Model.Info)<br />
{<br />
<tr><br />
<td><br />
@Html.DisplayFor(modelItem => item.CompanyName)<br />
</td><br />
<td><br />
@Html.DisplayFor(modelItem => item.CompanyID)<br />
</td><br />
</tr><br />
}<br />
</tbody>