Geodatabase Edits - Features deleted from attribute table but visible on map

881
4
Jump to solution
03-23-2021 11:53 PM
PrashantKirpan
Occasional Contributor

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 

 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
PrashantKirpan
Occasional Contributor

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

View solution in original post

0 Kudos
4 Replies
GintautasKmieliauskas
Regular Contributor

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

 

0 Kudos
PrashantKirpan
Occasional Contributor

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

View solution in original post

0 Kudos
SeanJones
Esri Regular Contributor

With the callback you can also try invalidating the row both before (as you have) and after the delete call.

0 Kudos
PrashantKirpan
Occasional Contributor

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

0 Kudos