Can ServiceModel specify ordering?

Is it possible to add ordering on the service model?

I know I could specify ordering at the service interface level:

public async Task<List<Application>> GetApplicationsAsync()
{
    using var db = AutoQuery!.GetDb<Application>(Request);
    var find = new SearchApplication();
    var q = AutoQuery.CreateQuery(find, Request, db);
    q.OrderBy("Code");
    var result = await db.SelectAsync(q);
    return result.Results;
}

However, I only define service implementations when necessary (e.g. business logic). So, for simple database queries, I would only have the service model:

[Route("/api/search/application", "GET")]
public class SearchApplication : QueryDb<Application>, IGet
{
	public Guid? Id { get; init; }
	public string? Code { get; set; }
}

Use the OrderBy and OrderByDesc properties. They also support ordering by multiple columns as well as - prefix to order by descending e.g:

?orderBy=Id,-Age,FirstName

Thank you for the quick weekend response.

So, how would I apply those properties to the Service model definition of SearchApplication below?

[Route("/api/search/application", "GET")]
public class SearchApplication : QueryDb<Application>, IGet
{
	public Guid? Id { get; init; }
	public string? Code { get; set; }
}

They’re already in the base class of QueryDb/QueryBase.

Perfect, thank you very much.

One last question, I hope: how could I use the QueryBase properties for to define mixed ordering, such as:

ORDER BY
     CountryName
    ,LocationName DESC   -- how to use QueryBase?
    ,CompanyName

I showed the mixed ordering example in my comment above, i.e. you can use a - prefix to specify descending order:

?orderBy=CountryName,-LocationName,CompanyName

With DTO:

new SearchApplication {
    OrderBy = "CountryName,-LocationName,CompanyName"
}

Sorry about not remembering that tip.

Great as always, thank you.