O'Reilly logo

Learning Azure DocumentDB by Riccardo Becker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deleting documents

In this section, we will demonstrate how to delete a document from your collection. DocumentDB does not support deleting batches of documents or a whole range of documents. You need to delete them one by one, using the SelfLink property.

The following code snippet demonstrates how to delete a single document:

var documentByLinqToObjects = client.CreateDocumentQuery<PersonInformation>(collection.DocumentsLink) .Where(personInformation => personInformation.FirstName.Equals("Riccardo") && personInformation.LastName.Equals("Becker")).AsEnumerable<PersonInformation>().First(); ////if the document exists, delete it and recreate it. if (null != documentByLinqToObjects) { await client.DeleteDocumentAsync(documentByLinqToObjects.SelfLink); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required