Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Group by and Order by in View

$
0
0

I have category title using a Group By and want to order by the display order of the title. Each category is number by a display order field and I want to order by  the display order. How do I do that with the group by that I already have.

 @foreach (var linkGroup in Model.Links.GroupBy(l => l.LinkCategory, LinkCategory.CategoryIdComparer))
                        {<div class="card forum-blue"><div style="color:black"><h4 class="bg-forum-blue" style="padding: 4px; color: white">@linkGroup.Key.Title</h4><hr />
                                    @foreach (var link in linkGroup)
                                    {<p style="padding:4px"><tr><td><a href="@link.Url" target="_blank">@link.Title</a><br> @Html.Raw(@link.Description)</td></tr></p>
                                    }</div></div><br />
                        }

Have something like this but I get an error

 @foreach (var linkGroup in Model.Links.GroupBy(l => l.LinkCategory, LinkCategory.CategoryIdComparer).Select(g => g.OrderByDescending(d => d.Order)).ToList())

on

@linkGroup.Key.Title

Possible Multiple enumerations


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>