Im playing around with ravendb trying to create a blog.
Im using Ravens own ID meaning that a document can look like this:
BlogPosts/1
{
"Title": "Ny post",
"Text": "Nytt blogginlägg",
"Kategori": "spel"
}
I fetch all my BlogPosts with this code:
var blogPosts = Session.Query<BlogPost>().ToList();
In my view, I loop through all the Blogposts like this:
@foreach (var item in Model.BlogPosts)
{
<div class="media">
<div class="media-body">
<h3 class="media-heading">@item.Title</h3>
<p>@item.Text</p>
</div>
<a class="view-info" href="#"><span>@item.Kategori</span></a>
</div>
}
My problem is this, everytime I create a new blogpost, the blogpost is given an ID higher than the one created before...In my view, I would like to display the blogpost with the higest number(the newest) first.
Can I use a sortOrder on this line maybe?
var blogPosts = Session.Query<BlogPost>().ToList();