Execution of DML Statements
On this page
In SQL mode, dotConnect for MongoDB supports INSERT, INSERT ... SELECT, UPDATE, and DELETE statements. Each document in a collection is identified by the value and type of its _id field.
Execution of INSERT Statements
- If an INSERT statement doesn't specify the _id field, dotConnect for MongoDB generates an ObjectId value for it on the client side.
- INSERT ... SELECT statements are supported.
- An INSERT statement that targets a nonexistent collection fails with the "no such table" error unless the Create Collection On Insert connection string parameter is set to True (it's False by default).
- If the Allow Add Fields connection string parameter is set to False, inserting a field that doesn't exist in any document of the collection fails with an error, for example: The collection "customers" has no field "extra" (Allow Add Fields=false).
Execution of UPDATE Statements
- An UPDATE statement can have any WHERE clause, including expressions, the LIKE operator, and functions.
- dotConnect for MongoDB finds the documents to update by the value and type of the _id field. For example, the _id values 1 and '1' identify different documents. An ObjectId value matches its hex string representation in any letter case, for example:
WHERE _id = '652f1c9e8a1b2c3d4e5f6a7b'.
- dotConnect for MongoDB sends the $set operator only for the changed fields and preserves the types of the stored values.
- If the Allow Add Fields connection string parameter is set to False, writing a field that doesn't exist in the document fails with an error.
Execution of DELETE Statements
- A DELETE statement can have any WHERE clause, including expressions, the LIKE operator, and functions.
- dotConnect for MongoDB finds the documents to delete by the value and type of the _id field.
- The DELETE command generated by MongoDBCommandBuilder deletes documents by the _id field.
Limitations
Batch updates (the UpdateBatchSize property of MongoDBDataAdapter set to a value other than 1) and the ExecuteArray method aren't supported and throw NotSupportedException.