I use the following code to read data from database and demonstrate them in a dropdown list:
@{
int m = 1;
foreach (var item in Model.MessagesList)
{
if (@item.receiverUserId == userId)
{
<li>
<a class="dropdown-item message-item" asp-controller="Messages" asp-action="Index" id="msg-@m"> @Model.UsersList.Where(x => x.Id == item.senderId).Select(x => x.department).First()</a>
</li>
m++;
}
}
}
I want to revers the order of items. What is the best method?
if its coming from a DB why not just use Order By?