AnsweredAssumed Answered

Is there a simple way to count number of features returned by IMapServer3 object

Question asked by cheesle on Apr 7, 2020
Latest reply on Apr 9, 2020 by cheesle

Using the arcobjects SDK (10.7.1) I am simply trying to count the number of features returned by a feature service query, here is some sample code:


    IMapServer3 ms = (IMapServer3) this.mapServerDataAccess;


    // query for relevant features using spatial filter
    QueryResult queryResult = (QueryResult) ms.queryData(mapName,
        getTableDescription(mapServerInfo, layerId),
        spatialFilter, qResultOptions);
    RecordSet rs = (RecordSet) queryResult.getObject();


I can count the number of features returned by getting a cursor and iterating through the cursor items incrementing a counter along the way but this is extremely slow and when working with layers with 2+ million points this is not feasable.  Is there a way of getting the count of the number of features in the returned RecordSet?  I couldn't see anything obvious.


Appreciate your help.