Unable to enumerate features in feature layer table.

458
5
Jump to solution
12-07-2023 12:06 PM
MoyerSolutions
New Contributor III

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)

MoyerSolutions_0-1701978473340.png

 

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?

 

 

0 Kudos
1 Solution

Accepted Solutions
MoyerSolutions
New Contributor III

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);

 

 

View solution in original post

0 Kudos
5 Replies
ThadTilton
Esri Contributor

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.

0 Kudos
MoyerSolutions
New Contributor III

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: 

MoyerSolutions_0-1702326059296.png

 

I'm digging around the properties but the only difference I can find between them is them is:

  • Plot  = Data Type: Feature Service Feature Class
  • Tally = Data Type: Feature Service Table

 

Is there some sort of flag or setting I should look for?

 

 

 

0 Kudos
MoyerSolutions
New Contributor III

Did some more investigation. Turns out was pointed to the wrong service endpoint....

User error! Or rather developer error in this case...

0 Kudos
MoyerSolutions
New Contributor III

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.

0 Kudos
MoyerSolutions
New Contributor III

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);

 

 

0 Kudos