I set the definition query on my feature layer to show what I want by year. However sometimes I want to query past years, so i have a function that sets the Definition Query to include all years, then I query the feature layer, then set the definition query back. I notice that in the beginning the SetDefinitionQuery works very fast, but the more times i use this function that SetDefinitionQuery sometimes takes up to 10 seconds or more. What could be happening here?
<SPAN class="keyword token">string</SPAN> currentDefinitionQuery <SPAN class="operator token">=</SPAN> <SPAN class="token function">GetLayerDefinitionQuery</SPAN><SPAN class="punctuation token">(</SPAN>layerName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
BasicFeatureLayer searchLayer <SPAN class="operator token">=</SPAN> FeatureServiceManagement<SPAN class="punctuation 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="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>searchLayer <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
searchLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetDefinitionQuery</SPAN><SPAN class="punctuation token">(</SPAN>inDefinitionQuery<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// define a spatial query filter</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> inWhereClause<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>
searchLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetDefinitionQuery</SPAN><SPAN class="punctuation token">(</SPAN>currentDefinitionQuery<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>