Created
March 15, 2016 06:59
-
-
Save EricAtMSFT/d9d46317b43b24177a77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Checks if the defined document database and collection exists | |
/// and initializes them if they don't. | |
/// </summary> | |
public async Task InitializeDatabaseIfNotExisting(string serverPath) | |
{ | |
var database = _documentClient.CreateDatabaseQuery() | |
.Where(db => db.Id == _documentDataBaseId) | |
.AsEnumerable() | |
.FirstOrDefault(); | |
if (database == null) | |
{ | |
database = await CreateDocumentDbDatabase(); | |
} | |
var documentCollection = _documentClient.CreateDocumentCollectionQuery(database.SelfLink) | |
.Where(c => c.Id == _documentCollectionId) | |
.AsEnumerable() | |
.FirstOrDefault(); | |
if (documentCollection == null) | |
{ | |
await CreateDocumentDbCollection(database); | |
} | |
await InitializeStoredProceduresIfNotExisting(serverPath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment