Hi,
I'm trying to delete features from filegeodatabase feature class. After executing edit operation, features get deleted from attribute table but still appearing on Map.
I'm referring following code snippet : https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase#deleting-a-rowfeature
Here is my sample code:
await QueuedTask.Run(() =>
{
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath))))
using (FeatureClass enterpriseTable = geodatabase.OpenDataset<FeatureClass>("PointFeature"))
{
EditOperation editOperationForPoints = new EditOperation();
editOperationForPoints.Callback(context =>
{
QueryFilter deleteFilter = new QueryFilter { WhereClause = $"OBJECTID NOT IN (27)" };
using (RowCursor rowCursor = enterpriseTable.Search(deleteFilter, false))
{
while (rowCursor.MoveNext())
{
using (Feature row = (Feature)rowCursor.Current)
{
context.Invalidate(row);
row.Delete();
}
}
}
}, enterpriseTable);
try
{
deletionResult = editOperationForPoints.Execute();
if (!deletionResult) message = editOperationForPoints.ErrorMessage;//"Edit operation failed."
}
catch (GeodatabaseException exObj)
{
message = exObj.Message;
}
}
});
.Execute() returning true value but ErrorMessage says "Edit operation failed."
Any help would be appreciated.
Prashant
Solved! Go to Solution.
Hi,
Thanks for the reply. Called await Project.Current.SaveEditsAsync(); after success of edit operation and working fine. Working in both callback and without callback
-Prashant
Hi,
Have you tried deleting without callback?
Just:
using (Feature row = (Feature)rowCursor.Current)
{
editOperationForPoints.Delete(row);
}
More info here:
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic9512.html
EditOperation ErrorMessage you can set which you want. If it is not set, you see default message.
editOperationForPoints.ErrorMessage = "My error message";
Hi,
Thanks for the reply. Called await Project.Current.SaveEditsAsync(); after success of edit operation and working fine. Working in both callback and without callback
-Prashant
With the callback you can also try invalidating the row both before (as you have) and after the delete call.
Hi SeanJones,
Yes, I tried that too. Even I tried to set null geometry, store feature and then delete but if I don't call save edits then issue persists.
-Prashant