I have a list in the Sales model where I usually display all the products, but now I need to display the category to which they belong, but only once, for each product category, how could I do this?
This is an example of what I want to do
Product Quantity Price
*Licors
Brugal 1 500
Barcelo 15 700
*Fruits
Apple 1 25
Banana 3 5
This is my code, the description I want to show is in item.Product.Category.Description
<table>
<thead>
<tr>
<th class="center"></th>
<th>Serv./Prod.</th>
<th class="center">Cant.</th>
<th class="right">Precio</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.SalesDetails.OrderBy(p=>p.Product.CategoryId))
{
<tr>
<td class="center"></td>
<td class="left"> @Html.DisplayFor(modelItem => item.Product.Name)</td>
<td class="right"> @Html.DisplayFor(modelItem => item.Quantity)</td>
<td class="center"> @Html.DisplayFor(modelItem => item.Product.SellPrice)</td>
</tr>
}
</tbody>
</table>