Skip to content

Instantly share code, notes, and snippets.

@AzimUddin
Last active September 2, 2015 21:29
Show Gist options
  • Save AzimUddin/4d94baae6c9d299811be to your computer and use it in GitHub Desktop.
Save AzimUddin/4d94baae6c9d299811be to your computer and use it in GitHub Desktop.
An example of querying Master resources in Azure DocumentDB
// Check if database exists, if not create it
Database database = client.CreateDatabaseQuery().Where(db => db.Id == id).ToArray().FirstOrDefault();
if (database == null)
{
database = await client.CreateDatabaseAsync(new Database { Id = id });
}
// Get collection
StudentsCollection = client.CreateDocumentCollectionQuery(database.SelfLink).Where(c => c.Id == collectionId).ToArray().FirstOrDefault();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment