Hello! This is a follow up to a previous question.
I am trying to read the values in a table. I guess their called attributes in this context. How do I enumerate the rows in the table and read the actual values of the fields?
Its an offline geodatabase, its is correctly download via the GeodatabaseSyncTask.GenerateGeodatabase()
Now I am trying to enumerate the values in the fields. The fields are loaded via table.LoadAsync(), and the field object contains the Field Name and other properties, but not the value.
I think I need ArcGISFeature.GetAttributeValue(field)? But how do I get the feature object from the table?
foreach (GeodatabaseFeatureTable table in geodatabase.GeodatabaseFeatureTables) {
await table.LoadAsync();
string message = "";
foreach (Field field in table.Fields) {
ArcGISFeature feature = ?????
object value = feature.GetAttributeValue(field);
message += "\n" + field.Name + ": " + value;
}
await Application.Current.MainPage.DisplayAlert(table.TableName, message, "OK");
}
Solved! Go to Solution.
Hi @MoyerSolutions , a quick way to get the values you're looking for is as follows:
foreach (GeodatabaseFeatureTable table in geodatabase.GeodatabaseFeatureTables)
{
await table.LoadAsync();
string message = "";
QueryParameters queryParams = new QueryParameters()
{
WhereClause = ""
};
FeatureQueryResult result = await table.QueryFeaturesAsync(queryParams);
foreach (Field field in table.Fields)
{
foreach (ArcGISFeature feature in result)
{
object value = feature.GetAttributeValue(field);
message += "\n" + field.Name + ": " + value;
}
await Application.Current.MainPage.DisplayAlert(table.TableName, message, "OK");
}
}
Hi @MoyerSolutions , a quick way to get the values you're looking for is as follows:
foreach (GeodatabaseFeatureTable table in geodatabase.GeodatabaseFeatureTables)
{
await table.LoadAsync();
string message = "";
QueryParameters queryParams = new QueryParameters()
{
WhereClause = ""
};
FeatureQueryResult result = await table.QueryFeaturesAsync(queryParams);
foreach (Field field in table.Fields)
{
foreach (ArcGISFeature feature in result)
{
object value = feature.GetAttributeValue(field);
message += "\n" + field.Name + ": " + value;
}
await Application.Current.MainPage.DisplayAlert(table.TableName, message, "OK");
}
}
Aha! I was knew I was close... Thank you!