I am in the process of upgrading my users from ArcGIS Pro 2.2.3 to 2.4.3. I have run into this issue. I have a function that returns only the ObjectIDs for a where clause applied to a basicfeaturelayer. I do this in order to get a quick list of features based on a simple where clause. I just return the SubFields of OBJECTID in the query filter to optimize the efficiency of the return rowcursor.
When I moved to ArcGIS Pro 2.4.3, the queryfilter subfields value of "OBJECTID" seems to not work any longer. In fact, the resulting rowcursor seems to return all records. In order to get the query to work correctly I added shape to the subfields value and now the query works again. "Shape, OBJECTID". However, I think this might be affecting my efficiency as I only need the OBJECTIDS. Is this a bug or is there a different way to return the rowcursor of just the subfields of ObjectID?
BasicFeatureLayer searchLayer <SPAN class="operator token">=</SPAN> <SPAN class="token function">GetBasicFeaturLayer</SPAN><SPAN class="punctuation token">(</SPAN>layerName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//This subfields fails in 2.4.3 I cant use just objectid in the subfield after the upgrade</SPAN>
<SPAN class="comment token">//string inSubFields = "OBJECTID";</SPAN>
<SPAN class="comment token">//This subFields works, i had to add an additional field in order for this to work in //2.4.3</SPAN>
<SPAN class="keyword token">string</SPAN> inSubFields <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Shape, OBJECTID"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> queryFilter <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">QueryFilter</SPAN>
<SPAN class="punctuation token">{</SPAN>
WhereClause <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">string</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Format</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"{0} IN ('{1}')"</SPAN><SPAN class="punctuation token">,</SPAN> inIDFieldName<SPAN class="punctuation token">,</SPAN> ContainsClause<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="punctuation token">,</SPAN>
SubFields <SPAN class="operator token">=</SPAN> inSubFields
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// apply the spatial filter to the feature layer in question</SPAN>
RowCursor rowCursor <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
rowCursor <SPAN class="operator token">=</SPAN> searchLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Search</SPAN><SPAN class="punctuation token">(</SPAN>queryFilter<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//*******************************</SPAN>
<SPAN class="comment token">//This loop fails after the upgrade from 2.2, when i just use </SPAN>
<SPAN class="comment token">// objectid in the subfield the rowcurser seems to return every feature</SPAN>
<SPAN class="comment token">//*******************************</SPAN>
<SPAN class="comment token">//Add all the resulting objectIDs to a list to later load or use</SPAN>
<SPAN class="keyword token">while</SPAN> <SPAN class="punctuation token">(</SPAN>rowCursor <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN> <SPAN class="operator token">&&</SPAN> rowCursor<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MoveNext</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>rowCursor<SPAN class="punctuation token">.</SPAN>Current <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
featuresByIDList<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Add</SPAN><SPAN class="punctuation token">(</SPAN>rowCursor<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetObjectID</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>