Deleting Records
The Delete operation removes one or more records from the database and moves them to the Recycle Bin. The method accepts one record or more than one record, which supports both Lists and Arrays.
var accts = Database.Query<Account>()
.Where(a => a.Status__c == "Invalid")
.ToList();
Delete(accts);
Permanent Delete
The Delete method always moves the deleted native record to the Magentrix Recycle Bin. If it is required for the record to be permanently deleted, set the PermanentDelete flag.
Note: Please exercise caution as this flag removes the record permanently and the records deleted can no longer be restored using the Recycle Bin.
An example of performing a permanent delete:
Delete(accts, new { PermanentDelete = true });
Processing in System Mode
The ​Magentrix for Database operation validates the user's access and verifies that the user has the "create" or "update" permission as necessary. However, in some scenarios, the database operation should take place regardless of the user's permission. In such cases, use the SystemMode flag.
Delete(accts, new { SystemMode = true });
Transactional Commit
If you wish all records to be committed together or rolled back in case of an error, set the AllOrNone flag to true. This flag by default is false.
Delete(accts, new { AllOrNone = true });
See Database Options for more details.