AutoQuery - Multiple connection

Continuing the discussion from Autoquery Change IDbConnection:

Above method is working very nice but when I try to insert my logic in service, AutoQuery always use defult connection

public object Get(QueryExampleDto request)
{
    //some logic
    //here request.NamedConnection = "db1" and object Db points to correct connection
			
    var q = AutoQuery.CreateQuery(request, Request.GetRequestParams());
    ///here q points to default connection?
    return AutoQuery.Execute(request, q);
}

Am I doing something wrong or is this a bug in prerelease version?

The example you’re showing in comments is modifying the request DTO, that’s not going to doing anything.

Please provide the request filter implementation that is populating req.Info[Keywords.DbInfo] and the full Request DTO class definitions. Its not clear how/where you’re changing the Db connection.

That is not code in comments - I just wanted to say that NamedConnection string is sucesfully passed into request.

I followed yours instructions:

public override void Configure(Container container)
{            
...
    RegisterTypedRequestFilter<IChangeDb>((req, res, dto) => req.Items[Keywords.DbInfo] = new ConnectionInfo { NamedConnection = dto.NamedConnection }); 
....
}

public interface IChangeDb
{
    string NamedConnection { get; set; }
}

[Route("/query/example/")]
public class QueryExampleDto : QueryBase<Example>, IChangeDb
{	
    public string NamedConnection { get; set; }
}

public object Get(QueryExampleDto request)
{
    //some logic that does not change request   			

    var q = AutoQuery.CreateQuery(request, Request.GetRequestParams());
    return AutoQuery.Execute(request, q);
}

Ok if you’re using AutoQuery manually, you need to pass IRequest into AutoQuery, e.g:

var q = AutoQuery.CreateQuery(request, Request.GetRequestParams(),Request);

That worked perfectly.
Thank you.