Page 1 of 1

Auto Query Max Limit

PostPosted: Mon Sep 17, 2018 3:37 pm
by SBarnes
Hi Mike

Is there a value that the api's max limit can be set to that makes it infinite?

Re: Auto Query Max Limit

PostPosted: Wed Sep 26, 2018 7:22 pm
by SBarnes
Bump

Re: Auto Query Max Limit  Topic is solved

PostPosted: Tue Mar 26, 2019 3:41 pm
by Mike.Sheen
Just not setting it to any value is the equivalent of infinite.

We, however, set the value in our standard REST API plugin to be the value of a System Setting - "AutoQueryMaxLimit" - and if that's invalid or not present we default to 100.

You could modify our standard plugin from this:
Code: Select all
// Add AutoQuery plugin
AppHost.Plugins.Add(new AutoQueryFeature() { EnableAutoQueryViewer = true, MaxLimit = autoQueryMaxLimit });

 AppHost.Plugins.Add(new AutoQueryDataFeature { MaxLimit = autoQueryMaxLimit });

To this:
Code: Select all
// Add AutoQuery plugin
AppHost.Plugins.Add(new AutoQueryFeature() { EnableAutoQueryViewer = true});

 AppHost.Plugins.Add(new AutoQueryDataFeature);


Which would do it - but that's not ideal as modifying our standard plugin isn't recommended and operating on a copy whilst is recommended over editing our standard plugin, you have a whole new set of problems when upgrading in the future and trying to merge in any new changes to the standard plugin to your copied one.

So the ideal solution is to create a new plugin to override the MaxLimit of the AutoQuery plugins to be null, effectively removing any limits:

Code: Select all
public void Configure(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin, ServiceStack.ServiceStackHost  AppHost, Funq.Container Container, JiwaApplication.Manager JiwaApplicationManager)
{
   foreach(IPlugin plugin in AppHost.Plugins)
   {
      if (plugin is AutoQueryDataFeature)
      {
         AutoQueryDataFeature autoQueryDataFeaturePlugin = (AutoQueryDataFeature)plugin;
         autoQueryDataFeaturePlugin.MaxLimit = null;               
      }
      else if (plugin is AutoQueryFeature)
      {
         AutoQueryFeature autoQueryFeaturePlugin = (AutoQueryFeature)plugin;
         autoQueryFeaturePlugin.MaxLimit = null;               
      }
   }         
}


Sample plugin with the above is attached.