Hello! I am trying to enumerate attributes in a feature layer table. Another follow up to a previous question.
Using GeodatabaseFeatureTable.QueryFeaturesAsync(new() { WhereClause = "" }) to load all values.
This has worked for the Tally table, but not the Plot table in the feature layer. The only difference I see is Type: Layer(Hosted) vs Type: Table(Hosted)
GeodatabaseFeatureTable table = geodatabase.GetGeodatabaseFeatureTable("Plot");
await table.LoadAsync();
QueryParameters queryParams = new() { WhereClause = "" }; //all
FeatureQueryResult result = await table.QueryFeaturesAsync(queryParams);
IEnumerable<ArcGISFeature> features = result.Cast<ArcGISFeature>();
int count = features.Count(); //break here, 0 results????
Am I missing an argument? Is there a different API for loading features from the table in layers?
Solved! Go to Solution.
There were some extent issues. Rather than hardcode, turns out you can grab the full extent via: `GeodatabaseSyncTask.ServiceInfo.FullExtent`
This should include all data.
GeodatabaseSyncTask gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(featureServiceUri));
GenerateGeodatabaseParameters generateParams = await gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(gdbSyncTask.ServiceInfo.FullExtent);
I tested your code using the ArcGIS Maps SDKs for .NET samples and it worked as expected. Maybe this can help you troubleshoot (?).
Using the "Display feature layers" sample, I added the following lines from your code at this location: https://github.com/Esri/arcgis-maps-sdk-dotnet-samples/blob/main/src/WPF/WPF.Viewer/Samples/Layers/D...
QueryParameters queryParams = new QueryParameters { WhereClause = "" }; //all
FeatureQueryResult result = await trailheadsGeodatabaseFeatureTable.QueryFeaturesAsync(queryParams);
IEnumerable<ArcGISFeature> features = result.Cast<ArcGISFeature>();
int count = features.Count(); //break here, 0 results????
For this geodatabase, 'count' had a value of 475.
Hmm, I get 475 results also with that test.
I can't seem to find the difference in why it works there and on the Tally table, but not the Plot table.
If I change only the Table name, I get different results:
//works: we get results!
GeodatabaseFeatureTable table = geodatabase.GetGeodatabaseFeatureTable("Tally");
//doesn't work: 0 results?
GeodatabaseFeatureTable table = geodatabase.GetGeodatabaseFeatureTable("Plot");
So the code must be correct, leading me to believe it's config related?
I expect 2 results from the current Plot table:
I'm digging around the properties but the only difference I can find between them is them is:
Is there some sort of flag or setting I should look for?
Did some more investigation. Turns out was pointed to the wrong service endpoint....
User error! Or rather developer error in this case...
Reopened the issue. Turns out not the full story. I was able to in one case to load 1 item of 3 but the others in one case. I am now unable to reproduce this partially working result.
Now again I am unable to load any items, regardless of what data is in the table.
I do not understand why the geodatabase does not contain all the features, or the query is not returning all features in the table.
There were some extent issues. Rather than hardcode, turns out you can grab the full extent via: `GeodatabaseSyncTask.ServiceInfo.FullExtent`
This should include all data.
GeodatabaseSyncTask gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(featureServiceUri));
GenerateGeodatabaseParameters generateParams = await gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(gdbSyncTask.ServiceInfo.FullExtent);