> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with Delete

> How to delete large numbers of records in bulk.

Used to remove multiple records from a table, delete requires a table name and an array of primary key values. To avoid any unnecessary database server side-effects (long locks), NetServer internally processes the array of primary keys in batches of 1000.

Rules that govern **soft-delete** entities are still respected. This means delete doesn't physically remove the database record, but instead updates the SoftDeletedDate column.

The specified rows are deleted in an efficient way yet the time taken is proportional to the number of rows deleted.

```csharp theme={null}
Delete(string tableName, int[] primaryKeys)
```

<Warning>
  Mass operations do not work on these [protected-tables][1].
</Warning>

## Example

<Tabs>
  <Tab title="Agent RESTful API">
    ```csharp theme={null}
    using SuperOffice.WebApi;
    using SuperOffice.WebApi.Data;
    using SuperOffice.WebApi.Agents;

    // set up the DatabaseTable agent

    WebApiOptions options = //Get WebApiOptions with SystemUser Authorization
    var dbTableAgent = new SuperOffice.WebApi.Agents.DatabaseTableAgent(options);

    // set the table name and primary key parameters

    string tableName = "y_myExtraTableName";
    int[] primaryKeys = { 1,2,3,4,5,6,7,8,9 };

    // perform the delete operation

    var massOperationResult = await dbTableAgent.DeleteAsync(tableName, primaryKeys);

    // check the result status and print out the number of changes.

    if(massOperationResult.Success)
    {
        Console.WriteLine($"Deleted {massOperationResult.Deletes} records from {tableName}.");
    }
    ```
  </Tab>

  <Tab title="NetServer Core">
    ```csharp theme={null}
    using SuperOffice.Data.Dialect;

    // set the table name and primary key parameters

    string tableName = "y_myExtraTableName";
    int[] primaryKeys = {1,2,3,4,5,6,7,8,9};

    var mo = MassOperations.GetCurrent();

    // perform the delete operation

    MassResult massResult = mo.Delete(tableName, primaryKeys);

    // check the result status and print out the number of changes.

    if(massOperationResult.Success)
    {
        Console.WriteLine($"Deleted {massOperationResult.Deletes} records from {tableName}.");
    }
    ```
  </Tab>
</Tabs>

[1]: ./protected-tables


## Related topics

- [Working with preferences](/en/admin/preferences/update.md)
- [Working with Upsert](/en/api/bulk-operations/mass-operations/upsert.md)
- [Working with fields](/en/customization/screen-designer/admin/working-with-fields.md)
- [Working with tabs](/en/customization/screen-designer/admin/working-with-tabs.md)
- [Working with Truncate](/en/api/bulk-operations/mass-operations/truncate.md)
- [Working with tiles](/en/dashboard/learn/working-with-tiles.md)
