Wrong number of features result with QueryFeaturesAsync on a ServiceFeatureTable

426
3
05-26-2023 03:49 AM
Labels (1)
VíctorAE
New Contributor II

Hello,

I am using ArcGIS Runtime 100.15.0 .NET SDK, and I'm querying a ServiceFeatureTable that contains polylines with a simple where clause (ID='xxx'). If I a test the query in a browser the result is ok, n features, but when I execute the same query in code I get less features than it would be expected.

Maybe any relationship with the service?

Thanks in advance

 

This is my code

Esri.ArcGISRuntime.Data.ServiceFeatureTable featureTable = new Esri.ArcGISRuntime.Data.ServiceFeatureTable(new Uri(uri));

Esri.ArcGISRuntime.Data.QueryParameters queryParams = new Esri.ArcGISRuntime.Data.QueryParameters();

queryParams.WhereClause = strWhere;
queryParams.ReturnGeometry = true;

queryParams.OutSpatialReference = ControlObjMap.General.MapaActivoVGIS.ObjetoMapa.map1.SpatialReference;

Esri.ArcGISRuntime.Data.FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);

 

But also I tried this code with all parameters setted

Esri.ArcGISRuntime.Data.ServiceFeatureTable feature_Pruebas =
new Esri.ArcGISRuntime.Data.ServiceFeatureTable(new Uri(uri));

Esri.ArcGISRuntime.Data.QueryParameters queryParams_Pruebas = new Esri.ArcGISRuntime.Data.QueryParameters
{
MaxAllowableOffset=99999,
ResultOffset=10,
SpatialRelationship = Esri.ArcGISRuntime.Data.SpatialRelationship.Equals,
WhereClause = strWhere,
ReturnGeometry = true,
OutSpatialReference = ControlObjMap.General.MapaActivoVGIS.ObjetoMapa.map1.SpatialReference
};

var taskQuery_Pruebas = feature_Pruebas.QueryFeaturesAsync(queryParams_Pruebas);
taskQuery_Pruebas.Wait();
Esri.ArcGISRuntime.Data.FeatureQueryResult queryResult_Pruebas = taskQuery_Pruebas.Result;

0 Kudos
3 Replies
JoeHershman
MVP Regular Contributor

Can you run fiddler to look at the query sent across?  Runtime is just a wrapper for the same rest calls made via a browser, so not sure why you would see a difference

Thanks,
-Joe
JenniferNery
Esri Regular Contributor

Inspecting fiddler capture will definitely help you troubleshoot whether the query you're making on the browser is identical to the request made through Runtime. 

In addition should they be different...

A quick check if you will need to use paging query is to FeatureTable.QueryFeatureCountAsync if the result is more than the LayerInfo.MaxRecordCount and LayerInfo.SupportsPagination is true, you can pass a ResultOffset and MaxFeaturesCount in the QueryParameters. Another cause why query result count is different from server is you may have set a DefinitionExpression on the table which will limit the features accessible to you.

 

VíctorAE
New Contributor II

Fiddler showed me the difference. The problem is the result of the service which contains records with same ESRI_OID. In Runtime you cannot change "Return Distinct Values" (is set true), meanwhile in the browser default mode is false

0 Kudos