Jake Pearson
Jake Pearson

Reputation: 27717

Order by ID in RavenDB

Is there a way to have Raven order the results of a query by the Id field as if it was in integer. So "cars/2" would come before "cars/11" if I did this query:

var cars = session.Query<Car>().OrderBy(c => c.ID);

Upvotes: 4

Views: 830

Answers (1)

Ayende Rahien
Ayende Rahien

Reputation: 22956

You shouldn't rely on the id of the document to be sortable in any way. Add a CreatedAt property or something similar and use that

Upvotes: 8

Related Questions