AnsweredAssumed Answered

Getting Distinct Values - ArcGIS .NET SDK

Question asked by ArborBandricks on Aug 27, 2018
Latest reply on Aug 29, 2018 by ArborBandricks

We have a workflow where we are building a search control to allow users to search through data in a custom application written with the ArcGIS .NET SDK. This is an offline application that uses mobile geodatabases (.geodatabase) to store and sync back when in a service area. We are allowing the user to select 3 things:


1) a layer name from a dropdown (this is easy to query the map for layers and add the names to the dropdown list)

2) a list of fields from a dropdown (this is also easy as we can add this from the field list of each map layer and alter this list when the user selects a different layer name from the first dropdown)

3) this is our problem: we would like to have a third dropdown that is populated with a list of distinct values of the field that is selected. 


We need to be able to have something to the equivalent of SELECT DISTINCT, however, if we attempt to query the feature table (QueryFeaturesAsync) we can only add to the property of the where statement, which does not allow for the DISTINCT prefix to be added to our query parameters.


Additionally, we tried to sort through the result that is returned for all results using "1=1" which returns a FeatureQueryResult but this takes a very long time to return - we have hundreds of thousands of records potentially being returned which we would then have to iterate through each to get the values and add them to the list if they do not already exist in the list. This is very poor programming methodology and is way to slow to be used in production.


We noticed that the REST Services API has a query parameter of returnDistinctValues. This is essentially what we need to use in the .NET sdk but it does not seem to exist. The ideal workflow would be to set a query parameter for the outFields to match our second dropdown value and then use the returnDistinctValues property set to 'true' to populate the third dropdown from the distinct results. 


This seems like a very basic task that we are able to run in the Enterprise GDB DBMS very easily and the returned list is very fast to complete. 


Looking for some assistance on this. Is it possible? Are we just missing something?