Tutorial by Examples

To connect to your DocumentDB database you will need to create a DocumentClient with your Endpoint URI and the Service Key (you can get both from the portal). First of all, you will need the following using clauses: using System; using Microsoft.Azure.Documents.Client; Then you can create the ...
Your DocumentDB database can be created by using the CreateDatabaseAsync method of the DocumentClient class. A database is the logical container of JSON document storage partitioned across collections. using System.Net; using System.Threading.Tasks; using Microsoft.Azure.Documents; using Microso...
A collection can be created by using the CreateDocumentCollectionAsync method of the DocumentClient class. A collection is a container of JSON documents and associated JavaScript application logic. async Task CreateCollection(DocumentClient client) { var databaseName = "<your database...
A document can be created by using the CreateDocumentAsync method of the DocumentClient class. Documents are user defined (arbitrary) JSON content. async Task CreateFamilyDocumentIfNotExists(DocumentClient client, string databaseName, string collectionName, Family family) { try { ...
DocumentDB supports rich queries against JSON documents stored in each collection. With a LINQ query IQueryable<Family> familyQuery = this.client.CreateDocumentQuery<Family>( UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), queryOptions) .Where(f => f....
DocumentDB supports replacing JSON documents using the ReplaceDocumentAsync method of the DocumentClient class. await client.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, familyName), updatedFamily);
DocumentDB supports deleting JSON documents using the DeleteDocumentAsync method of the DocumentClient class. await client.DeleteDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, documentName));
Deleting a database will remove the database and all children resources (collections, documents, etc.). await this.client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(databaseName));

Page 1 of 1