I'm trying to build an application to edit related table records and I'm building off of the code in this discussion, however, it "seems" I should be able to loop through the related features and update the "Comments" field to a value of "Test". When I run the following code it continues the loop and doesn't kick out once all results have cycled through. Not sure if I've got something wrong or there is something else going on.
If I comment out the await line in the loop, the process kicks out of the loop as expected....
var queryResults = await table.QueryRelatedFeaturesAsync(feature);
foreach (var queryResult in queryResults.ToArray())
{
foreach (var f in queryResult)
{
var sft = (GeodatabaseFeatureTable)f.FeatureTable;
var id = (long)f.Attributes[sft.ObjectIdField];
f.Attributes["Comments"] = "Test";
await f.FeatureTable.UpdateFeatureAsync(f);
}
}
This resolved the issue but seems you should be able to update the features individually instead all at one time...
var queryResults = await table.QueryRelatedFeaturesAsync(feature);
foreach (var queryResult in queryResults.ToArray())
{
List<Feature> _features = new List<Feature>();
foreach (var f in queryResult)
{
f.Attributes["Comments"] = "Test";
_features.Add(f);
}
await queryResult.RelatedTable.UpdateFeaturesAsync(_features);
}