Auto Query A bit Easier  Topic is solved

Discussions relating to the REST API of Jiwa 7.

Auto Query A bit Easier  Topic is solved

Postby SBarnes » Mon Nov 28, 2022 1:45 pm

In the past in adding auto queries I have created a service to run the auto queries today I have discovered an easier way in the configure method of your plugin as well as having the add route code add the following two lines and service stack will scan the plugin for auto query classes, make sure you plugin has a higher execution order than the REST API plugin though.



Code: Select all
var dll = GetType().Assembly;
AppHost.GetPlugin<AutoQueryFeature>().LoadFromAssemblies.Add(dll);
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Auto Query A bit Easier

Postby SBarnes » Fri Feb 03, 2023 5:24 pm

Well I worked out the answer for myself its as simple as on your service class declare the AutoQuery property like this


Code: Select all
public IAutoQueryDb AutoQuery { get; set; }


then inside your method do this, which is based upon the documentation of doing a custom auto query.

Code: Select all
      var req =  new JiwaFinancials.Jiwa.JiwaServiceModel.Tables.DB_MainQuery();
                var q = AutoQuery.CreateQuery(req, base.Request, Db);
                var result = AutoQuery.Execute(req, q, base.Request, Db);
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: No registered users and 2 guests

cron