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.
string url = "*******/FeatureServer/0";
Uri uri = new Uri(url);
ServiceFeatureTable sft = new ServiceFeatureTable(uri);
_mapViewModel.fireExLayer = new FeatureLayer(sft);
Then I query the feature layer and get the Selectedfeature. (I removed error checking code here)
var queryParams = convertTapToQuery(e.Location.X, e.Location.Y, 1);
var result = await _mapViewModel.fireExLayer.SelectFeaturesAsync(queryParams, SelectionMode.New);
_mapViewModel.SelectedFeature = result.ToList();
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!