ComponentOne DataObjects for .NET
Deleted Row
DataObjects for .NET (Enterprise Edition) > Updating the Database > Generated SQL Statements > Deleted Row

To delete a row from the database, DataObjects for .NET generates and executes the following SQL statement:

DELETE FROM table_name WHERE field1 = ? AND field2 = ? AND …

Parameter values are set to original row values: row["field_name", DataRowVersionEnum.Original].

If the original value of a field is Null, the condition is field IS NULLinstead of field = ?.

The collection of fields used to locate the record in the WHERE clause depends on the table property UpdateLocateMode and field properties UpdateIgnore and UpdateLocate:

Locating the record for delete can fail (no record found), due to changes made to the database by other users between the time the record was fetched and the time it is deleted. This is usually called optimistic concurrency; see Handling Concurrency Conflicts for more information. Including more fields in the WHERE clause (manipulating the UpdateLocateMode and UpdateLocate properties) makes the concurrency check stricter: changes made by other users to one of this field can fail the delete. Excluding fields from the WHERE clause makes the check less strict, allowing more concurrency, more tolerant to changes made by other users.

If no record has been found for delete, it may mean that the row has been already deleted. Since this does not necessarily represent an error condition (for example, the row could be deleted as a result of cascade delete), a special property IgnoreDeleteError allows you to suppress the error in this case. To check the "row deleted" condition DataObjects for .NET tries to locate the database row with the original primary key value (as in UpdateLocateMode = PrimaryKey). If such a row cannot be located, it means the row has been deleted. Handling this situation depends on the table property IgnoreDeleteError. If IgnoreDeleteError = True (default), this error is ignored, it does not generate an update error. If IgnoreDeleteError = False, this error generates an update error.