biddrafter
biddrafter

Reputation: 67

ServiceStack AutoQuery MaxLimit

Is there a way to customize the ServiceStack AutoQuery MaxLimit setting per DTO? I have a use case where I'd prefer a smaller MaxLimit for one DTO compared to another, but I've only been able to set the MaxLimit once:

var aqf = new AutoQueryFeature
{
     MaxLimit = 100
};

Upvotes: 1

Views: 166

Answers (1)

mythz
mythz

Reputation: 143374

There's only 1 MaxLimit configuration option but you can customize it on a per-request basis by providing a Custom Service implementation, e.g:

public class MyQueryServices : Service
{
    public IAutoQuery AutoQuery { get; set; }

    //Override with custom implementation
    public object Any(FindMovies request)
    {
        var q = AutoQuery.CreateQuery(request, Request.GetRequestParams());
        q.Limit(request.Skip, newTake); //override with custom limit
        return AutoQuery.Execute(request, q);
    }
}

Upvotes: 1

Related Questions