AnsweredAssumed Answered

Edit Operation failing when trying to Modify rows in a feature class

Question asked by KPerri-esristaff Employee on Dec 12, 2018
Latest reply on Dec 12, 2018 by KPerri-esristaff

I am trying to loop through every row in a feature class and edit one of it's fields, but for some reason it always fails.

Here is my code:

QueuedTask.Run(async () =>
            {
foreach(var featureClass in featureClasses)
                        {
                            var editOperation = new EditOperation()
                            {
                                Name = "Revert IsEdited Field",
                                EditOperationType = EditOperationType.Short,
                                ShowProgressor = false
                            };
                            var editedRowsQuery = new QueryFilter()
                            {
                                WhereClause = $"{IS_EDITED_FIELD} = 1"
                            };
                            try
                            {
                                using (var rowCursor = featureClass.Search(editedRowsQuery))
                                {
                                    int isEditedFieldIndex = rowCursor.FindField(IS_EDITED_FIELD);
                                    while (rowCursor.MoveNext())
                                    {
                                        using (var row = rowCursor.Current)
                                        {
                                            editOperation.Modify(row, isEditedFieldIndex, 0);
                                        }
                                    }
                                }
                            }
                            catch (System.ArgumentException)
                            {
                                continue;
                            }
                            catch (GeodatabaseException)
                            {
                                continue;
                            }
                            bool succeeded = await editOperation.ExecuteAsync();
                            featureClass.Dispose();
                        }
}

Is there something I'm doing wrong?

I've tried using editOperation.Execute as well, but same error.

Outcomes