I want to retrieve the records having a text inside the feature class irrespective of field name using Arcobjects.
Simply loop all fields of all records from your table:
IEnumerable<SPAN class="operator token"><</SPAN>IFeature<SPAN class="operator token">></SPAN> <SPAN class="token function">GetFeaturesBySearchValue</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">object</SPAN> searchValue<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> featureClass <SPAN class="operator token">=</SPAN> myWorkspace<SPAN class="punctuation token">.</SPAN><SPAN class="token function">OpenFeatureClass</SPAN><SPAN class="punctuation token">(</SPAN>fcName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> cursor <SPAN class="operator token">=</SPAN> featureClass<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Search</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> fields <SPAN class="operator token">=</SPAN> featureClass<SPAN class="punctuation token">.</SPAN>Fields<SPAN class="punctuation token">;</SPAN> IFeature feature<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">while</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>feature <SPAN class="operator token">=</SPAN> cursor<SPAN class="punctuation token">.</SPAN><SPAN class="token function">NextFeature</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <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">for</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">int</SPAN> i <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN> i <SPAN class="operator token"><=</SPAN> fields<SPAN class="punctuation token">.</SPAN>FieldCount <SPAN class="operator token">-</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN> i<SPAN class="operator token">++</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> theValue <SPAN class="operator token">=</SPAN> feature<SPAN class="punctuation token">.</SPAN><SPAN class="token function">get_Value</SPAN><SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>theValue <SPAN class="operator token">==</SPAN> searchValue<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">yield</SPAN> <SPAN class="keyword token">return</SPAN> feature<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>
Be aware to also release the features and the cursor when you´re done with them.
This would be how you verify the field type to be a text(string). Related samples are at the bottom. http://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#IField_Type.htm
Best of luck,
Jared
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.