Locode with QueryData

Trying to get Locode working with Data Service type AutoQuery. As long as the query DTO inherits from QueryDb type, the locode icon appears in the browser and the query endpoint gets called from the browser. When I change the DTO class to inherit from QueryData type, the Locode icon does not appear on the UI anymore. Is there a way to get Locode working with Data Service type of AutoQuery?

The query DTO in ServiceModel/Hello.cs file:

[Route("/hellos", "GET")]
public class QueryHellos : 
    QueryData<HelloResponse>,
    IReturn<QueryResponse<HelloResponse>>,
    IGet
{ 
}

ServiceInterface:

public class MyServices : Service
{
    public object Any(Hello request)
    {
        return new HelloResponse { Result = $"Hello, {request.Name}!" };
    }

    public List<HelloResponse> Get(GetHellos request)
    {
        return new List<HelloResponse>() { new HelloResponse { Result = "first" }, new HelloResponse { Result = "second" } };
    }
}

In Configure.AutoQuery.cs I’ve added call to:

appHost.Plugins.Add(
    new AutoQueryDataFeature { MaxLimit = 1000 }
    .AddDataSource(ctx => ctx.ServiceSource<HelloResponse>( new GetHellos()))
);

Am I missing something?

Yeah as you’ve discovered Locode only works with AutoQuery RDBMS, i.e. inheriting QueryDb<>.

If you only want to get data from your Data Service, then you can implement a Custom AutoQuery Service method, which calls your Data Service instead of the db (see last code box of https://docs.servicestack.net/autoquery/rdbms#custom-autoquery-implementations).
My “standard” service reads some subfolders from the filesystem and it returns the listing with this “proxy method” as a AutoQueryGrid. You can even link the pseudo db table with the Ref attribute in locode. :grinning:

1 Like