AutoQuery - different return type than searched type

We have a custom AutoQuery Service with a custom Any() method as shown here:

In the Operations file, our Find class inherits from QueryDb:

[ConnectionInfo(NamedConnection = "AutoQueryConnection")]
[Route("/query/Audit/", "GET")]
public class FindAudit : QueryDb<Audit>


However in the Service file, the custom Any returns a QueryResponse<AuditDto> and not QueryReponse<Audit>.

    public class AutoQueryService_Audit : AutoQueryService

        public async Task<QueryResponse<AuditDto>> Any(FindAudit query)

When we generate a dtos.ts file for our Angular programmers, FindAudit is defined as returning QueryResponse<Audit> and not QueryResponse<AuditDto>. Should we change FindAudit to inherit from QueryDb<AuditDto> ? will that work?

If you want to override AutoQuery API with a custom implementation it still needs to adhere to the API contract, e.g:

public class FindAudit : QueryDb<Audit> {}

Your custom API would still need to return QueryResponse<Audit> to adhere to its API contract.

If you want to return a Custom Result that’s different from the Data Model that’s being queried, you can specify it with:

public class FindAudit : QueryDb<Audit,AuditDto> {}

In which case your API should return an AuditDto to adhere to its contract.

Note the declared return type of the method signature is functionally equivalent, e.g:

public async Task<object> Any(FindAudit query)
public async Task<QueryResponse<AuditDto>> Any(FindAudit query)

and I would leave as object which allows for returning either T or a decorated HttpResult(T) which both return the same response body. It also makes clear that the implementation method signature isn’t important.

What matters is what return Type the API contract says it returns with IReturn<T>:

public class MyRequest : IReturn<MyResponse> {}

Which for AutoQuery Request DTO inheriting QueryDb<Table> is QueryResponse<Table> or inheriting QueryDb<From,Into> is QueryResponse<Into>.