I want to loop through each item in my model in my razor view but I want to group all items together. I then want to loop through each group. Imagine I have a table:
<
LINQ can help you do that
@model IEnumerable @foreach (var item in Model.Select(i=>i.groupno).Distinct().ToList()) { Group No is @item @foreach (var grpName in Model.Where(i => i.groupno == item).ToList()) { GroupName: @grpName.groupName } }
GroupName: @grpName.groupName