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.
using SuperOffice.WebApi;using SuperOffice.WebApi.Data;using SuperOffice.WebApi.Agents;// set up the DatabaseTable agentWebApiOptions options = //Get WebApiOptions with SystemUser Authorizationvar dbTableAgent = new SuperOffice.WebApi.Agents.DatabaseTableAgent(options);// set the table name and primary key parametersstring tableName = "y_myExtraTableName";int[] primaryKeys = { 1,2,3,4,5,6,7,8,9 };// perform the delete operationvar 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}.");}
using SuperOffice.Data.Dialect;// set the table name and primary key parametersstring tableName = "y_myExtraTableName";int[] primaryKeys = {1,2,3,4,5,6,7,8,9};var mo = MassOperations.GetCurrent();// perform the delete operationMassResult 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}.");}