ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Data Namespace / Row Class / Delete Method
Example

In This Topic
    Delete Method (Row)
    In This Topic
    Deletes the row. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void Delete()
    Public Sub Delete() 
    Exceptions
    ExceptionDescription
    This table/feature does not support this operation. For example, it is from a joined table.
    A geodatabase-related exception has occurred.
    Remarks
    Once delete is called on a Row, all subsequent queries against the table within the same session with this API will reflect the deleted state.
    Example
    Deleting a Row/Feature
    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);
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also