26 Sorting, paging and result sets
.OrderBy(Expression<Func<TNode, object>> expression, bool descending = false)
.OrderByDescending(Expression<Func<TNode, object>> expression)
.OrderByMeta(Expression<Func<NodeMeta, object>> expression, bool descending = false) // m => m.ChangedUtc
.OrderByMetaDescending(Expression<Func<NodeMeta, object>> expression)OrderByMeta sorts by the node's own CreatedUtc or ChangedUtc, on any type, whether or not the
class maps them (Querying by the node's own dates).
To sort by several keys, chain OrderBy calls. Each sort keeps the order that equal values already
had, so the last call is the main key, as with LINQ's OrderBy(…).OrderBy(…):
// By start time; events that start at the same time, dearest first
db.Query<IEvent>()
.OrderBy(e => e.Price, descending: true) // the tie-breaker first
.OrderBy(e => e.StartsUtc) // the main key last
.Execute();- Paging — Page(p, n) returns the same rows as .Skip(p * n).Take(n) and also records the page in the result. Either way, TotalCount is the number of matches before paging, so one query gives you both the page and the total. Use…
- ResultSet<T> — ResultSet<T> is an IEnumerable<T> with these members: