Steven Li
Steven Li

Reputation: 764

ServiceStack AutoQuery Is Null for Asp.Net.Core and NullReferenceException thrown at CreateQuery

I've done the Plugins.Add(new AutoQueryFeature { MaxLimit = 100 }); and used it in startup Configure Method.

enter image description here

enter image description here

This is dto inherites QueryDb

enter image description here

I keep encountering AutoQuery is null and NullReferenceException thrown at AutoQuery.CreateQuery() Method. And CallStacks can not show ExternalCodes. I have no ideas where it gone wrong by referring to TechStacks Project.

enter image description here

enter image description here

The project references ServiceStack.Core 5.7.0

I'm able to get AutoQuery by using the below code.

var autoquery = TryResolve<IAutoQueryDb>() 

enter image description here

Upvotes: 1

Views: 136

Answers (1)

mythz
mythz

Reputation: 143359

None of your code samples show the 3 important things required for AutoQuery, the AutoQueryFeature plugin registration in your AppHost’s Configure(), the definition of your Service class that implements the Service base class, the public IAutoQueryDb AutoQuery { get; set; } public property.

If they’re configured correctly the IAutoQueryDb dependency should be injected.

Upvotes: 1

Related Questions