Exception | Description |
---|---|
System.NotSupportedException | This table/feature does not support this operation. For example, it is from a joined table. |
ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
public async Task DeletingARowOrFeature() { string message = String.Empty; bool deletionResult = false; await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table enterpriseTable = geodatabase.OpenDataset<Table>("LocalGovernment.GDB.piCIPCost")) { //var geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(uri)) for a File GDB // //var shapeFileConnPath = new FileSystemConnectionPath(uri, FileSystemDatastoreType.Shapefile); //var shapefile = new FileSystemDatastore(shapeFileConnPath); //var table = shapefile.OpenDataset<Table>(strShapeFileName); for a Shape file EditOperation editOperation = new EditOperation(); editOperation.Callback(context => { QueryFilter openCutFilter = new QueryFilter { WhereClause = "ACTION = 'Open Cut'" }; using (RowCursor rowCursor = enterpriseTable.Search(openCutFilter, false)) { while (rowCursor.MoveNext()) { using (Row row = rowCursor.Current) { // In order to update the Map and/or the attribute table. Has to be called before the delete. context.Invalidate(row); row.Delete(); } } } }, enterpriseTable); try { deletionResult = editOperation.Execute(); if (!deletionResult) message = editOperation.ErrorMessage; } catch (GeodatabaseException exObj) { message = exObj.Message; } } }); if (!string.IsNullOrEmpty(message)) MessageBox.Show(message); }
Target Platforms: Windows 11, Windows 10