Hi,
I encountered a strange issue with pulling data from the feature service. The problem is that a feature pulled from a feature service loses some of the fields that was in its feature table. What I am doing is I pulled a feature layer hosted on the portal and queried the feature layer. The result feature, however, only contains a portion of the fields that are in its feature table.
Here I first created a feature layer from a service feature table.
<SPAN class="keyword token">string</SPAN> url <SPAN class="operator token">=</SPAN> <SPAN class="string token">"*******/FeatureServer/0"</SPAN><SPAN class="punctuation token">;</SPAN>
Uri uri <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Uri</SPAN><SPAN class="punctuation token">(</SPAN>url<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
ServiceFeatureTable sft <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ServiceFeatureTable</SPAN><SPAN class="punctuation token">(</SPAN>uri<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
_mapViewModel<SPAN class="punctuation token">.</SPAN>fireExLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN>sft<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Then I query the feature layer and get the Selectedfeature. (I removed error checking code here)
<SPAN class="keyword token">var</SPAN> queryParams <SPAN class="operator token">=</SPAN> <SPAN class="token function">convertTapToQuery</SPAN><SPAN class="punctuation token">(</SPAN>e<SPAN class="punctuation token">.</SPAN>Location<SPAN class="punctuation token">.</SPAN>X<SPAN class="punctuation token">,</SPAN> e<SPAN class="punctuation token">.</SPAN>Location<SPAN class="punctuation token">.</SPAN>Y<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> result <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> _mapViewModel<SPAN class="punctuation token">.</SPAN>fireExLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SelectFeaturesAsync</SPAN><SPAN class="punctuation token">(</SPAN>queryParams<SPAN class="punctuation token">,</SPAN> SelectionMode<SPAN class="punctuation token">.</SPAN>New<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
_mapViewModel<SPAN class="punctuation token">.</SPAN>SelectedFeature <SPAN class="operator token">=</SPAN> result<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
At last, I try to get the attributes of the SelectedFeature by doing this:

As seen in the screenshot, for each field in the feature table of a feature, I tried to get the attribute value of that field, but this triggers an exception, whose message says “the given key was not present in the dictionary.” I was bewildered seeing the field from a feature’s own feature table is not a key in the feature’s attribute dictionary.
What am I doing wrong here? Appreciate any help and thoughts!
Best,
Yifan