AutoQuery is not returning all fields

Hello,

Need advise on how I can debug how AutoQuery returns object data, I have 2 endpoints that have the same return type QueryData<> and both point to the same dataset (JSON in Redis) and the only difference is on the object is a field that is “Disabled=true/false” one endpoint return only Disabled=false and the other returns everything, the odd issue is that when calling both endpoints there are a couple fields missing from one and not the other.

Thanks,
Vic

Hi @vkhazen , It sounds like something is trying to return a null or empty object. Since bool has default value of false that will still be getting serialized. Can you share the endpoint and QueryData code you are using?

You should be able you debug custom AutoQuery services like any other services. The more you can share will help us reproduce the issue.

The cache is registered in AppHost() of Global.asax:

container.Register<IRedisClientsManager>(_ => new RedisManagerPool(AppSettings.GetList(RedisDebug)));
container.Register<IRedisClientsManagerAsync>(_ => new RedisManagerPool(AppSettings.GetList(RedisDebug)));

 var autoAueryDataFeature = new AutoQueryDataFeature { MaxLimit = 50000 }
     .AddDataSource(typeof(WindowsUser), ctx =>
     {
         switch (ctx.Dto)
         {
             case SearchWindowsDisabledUsers _:
                 return ctx.ServiceSource<WindowsUser>(new GetWindowsDisabledUsers(), HostContext.Cache,
                     TimeSpan.FromHours(20));
             case SearchWindowsUsersById _:
                 return ctx.ServiceSource<WindowsUser>(ctx.Dto.ConvertTo<GetWindowsUsersById>(),
                     HostContext.Cache, TimeSpan.FromHours(20));
             case SuggestWindowsUsers _:
                 return ctx.ServiceSource<WindowsUser>(ctx.Dto.ConvertTo<GetWindowsUsersById>(),
                     HostContext.Cache, TimeSpan.FromHours(20));
         }

the one in question -->         return ctx.ServiceSource<WindowsUser>(new GetWindowsUsers(), HostContext.Cache,
             TimeSpan.FromMinutes(5));
     })

I’m having difficulty finding out how HostContext.Cache is using either in-mem or is it referencing my Redis instance. When trying to debug I don’t see it calling GetWindowsUsers().

HostContext.Cache will return the registered ICacheClient which will check for a registered IRedisClientsManager and fallback to the DefaultCache which is a MemoryCacheClient.

You can be explicit about it by registering your ICacheClient directly after registering your redis manager.

container.Register<ICacheClient>(c => 
    c.Resolve<IRedisClientsManager>().GetCacheClient());

If you still want to use an in memory for specific situations, you can explicitly use HostContext.LocalCache.