Hello,
I am attempting to search the Attributes property of a Feature to find a specific field name.
FeatureLayer flayer = lyr as FeatureLayer;
FeatureQueryResult queryResult = await flayer.GetSelectedFeaturesAsync();
foreach (Feature feat in queryResult)
{
var catAtt = feat.Attributes.Where(x=>x.Key == "Category");
}
Although my FeatureLayer has 6 editable fields, I find that only 5 attributes are listed within the Attributes property. When I look for 'Category', the search does not return anything although I know the field exists. Is there something that I need to set up on the layer to return all of the Attributes when using the GetSelectedFeaturesAsync() method?
Thanks!
Jen
Solved! Go to Solution.
Try calling LoadAsync() on the feature. I assume your using a ServiceFeatureTable , with ServiceFeatureTable only a core set of attributes in returned by default in order to keep the response to a minimum. I believe the LoadAsync() will pull the entire feature with all attributes
Try calling LoadAsync() on the feature. I assume your using a ServiceFeatureTable , with ServiceFeatureTable only a core set of attributes in returned by default in order to keep the response to a minimum. I believe the LoadAsync() will pull the entire feature with all attributes
Hi Joe,
Thanks for your quick response! I was trying the addition of 'LoadAsync' on the feature today but I am still not getting all of the attributes. You are right that I am using an online feature service. When I look at the properties of the FeatureTable both before and after running LoadAsync() I do have all 10 fields but the attributes still include only 4 key,value pairs. Have I missed something here?
Thanks!
Jen
LayerCollection lyrColl = Map.OperationalLayers;
Layer lyr = lyrColl[0];
FeatureLayer flayer = lyr as FeatureLayer;
FeatureQueryResult queryResult = await flayer.GetSelectedFeaturesAsync();
foreach (Feature feat in queryResult)
{
await feat.FeatureTable.LoadAsync();
...and so on...
}
Hi Joe,
Just after I sent my last response I added another line of code to get the ArcGISFeature and that worked! Thanks for your reply, it essentially fixed my issue!
foreach (Feature feat in queryResult)
{
ArcGISFeature arcFeat = feat as ArcGISFeature;
await arcFeat.LoadAsync();
...
Jen
My reply did say call LoadAsync on the Feature.
I mention the type of feature table as clarification because the issue described would not occur with a feature from a GeodatbaseFeatureTable
You're right! That definitely answered my question.
Thanks!
Jen
If you know up front that you are for sure going to need all the attributes for all the features, you can set the QueryFeatureFields to "LoadAll" and it'll fetch all data.
The idea is that you might be querying 1000s of features, so instead of downloading ALL data, we fetch the minimum to render/display them, and once you click at a feature, you'd go and fetch the full data just for that one feature. So the default is configured for performance-first. However there might be cases where you know you'll get a very limited set of results back, or you know you're going to need all the attributes from all the features, and you can then use this call to avoid the extra LoadAsync call and webrequest.