Orderby on more than one property

Hi
I have a query like this:

static readonly IOrdering orderByDate = Ordering.Property("date").Descending()
    :
QueryBuilder.Select(
                    SelectResult.All())
                   .From(dbSource)
                   .Where(_condition)
                   .OrderBy(orderByDate)

If the date attribute is the same then I want creation order to be next order by criteria - similarly to this N1QL query:

select `key`,catchkeys,date,created 
from data 
where type = "FishingTrip" and userkey="2124DEFEC111BA8FC1257ED20034B387" 
order by date desc,created des

I have tried to find the syntax on doing this (and tried to play with the typeahead in VisualStudio) - but I have not found a solution :face_with_monocle:

Does anyone here know how to do that?

Thanks!

You can send an array to OrderBy

   QueryBuilder.Select(
                    SelectResult.All())
                   .From(dbSource)
                   .Where(_condition)
                   .OrderBy([orderByDate, orderByCreated])

Example in swift,

 let searchQuery = QueryBuilder
        .select(
            SelectResult.expression(Meta.id),
            SelectResult.all())
        .from(DataSource.database(db))
        .where(Expression.property("type").equalTo(Expression.string("hotel")))
        .orderBy ([Ordering.property("country").ascending(),Ordering.property("title").ascending()])
        .limit(Expression.int(limit))
1 Like

Thanks! I had missed that option - and it works fine :+1::slight_smile: