Пример #1
0
 /// <summary>
 /// Update the provided <paramref name="data"/> in the data store and persist the change.
 /// </summary>
 public void Update(TData data)
 {
     Logger.LogDebug("Updating data in the Azure database", "AzureDocumentDbDataStore\\Update");
     try
     {
         Logger.LogDebug("Getting existing document from the Azure database", "AzureDocumentDbDataStore\\Update");
         DateTime start            = DateTime.Now;
         Document documentToUpdate = AzureDocumentDbClient.CreateDocumentQuery(AzureDocumentDbCollection.DocumentsLink)
                                     .Where(d => d.Id == data.id)
                                     .AsEnumerable()
                                     .Single();
         DateTime mid = DateTime.Now;
         Logger.LogDebug(string.Format("Getting existing document from the Azure database took {0}", mid - start), "AzureDocumentDbDataStore\\Update");
         Logger.LogDebug("Replacing existing document in the Azure database", "AzureDocumentDbDataStore\\Update");
         ResourceResponse <Document> result = AzureDocumentDbHelper.ExecuteFaultTollerantFunction(() => AzureDocumentDbClient.ReplaceDocumentAsync(documentToUpdate.SelfLink, data).Result);
         DateTime end = DateTime.Now;
         Logger.LogDebug(string.Format("Replacing existing document in the Azure database took {0} and cost:r\n{1}", end - mid, result), "AzureDocumentDbDataStore\\Update");
     }
     finally
     {
         Logger.LogDebug("Updating data in the Azure database... Done", "AzureDocumentDbDataStore\\Update");
     }
 }
Пример #2
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     AzureDocumentDbClient.Dispose();
 }
Пример #3
0
 /// <summary>
 /// Remove all contents (normally by use of a truncate operation) from the data store and persist the change.
 /// </summary>
 public void RemoveAll()
 {
     Logger.LogDebug("Removing all from the Azure database", "AzureDocumentDbDataStore\\RemoveAll");
     try
     {
         ResourceResponse <DocumentCollection> result = AzureDocumentDbHelper.ExecuteFaultTollerantFunction(() => AzureDocumentDbClient.DeleteDocumentCollectionAsync(AzureDocumentDbCollection.SelfLink, new RequestOptions()).Result);
     }
     finally
     {
         Logger.LogDebug("Removing all from the Azure database... Done", "AzureDocumentDbDataStore\\RemoveAll");
     }
 }
Пример #4
0
 /// <summary>
 /// Add the provided <paramref name="data"/> to the data store and persist the change.
 /// </summary>
 public void Add(TData data)
 {
     Logger.LogDebug("Adding data to the Azure database", "AzureDocumentDbDataStore\\Add");
     try
     {
         DateTime start = DateTime.Now;
         ResourceResponse <Document> result = AzureDocumentDbHelper.ExecuteFaultTollerantFunction(() => AzureDocumentDbClient.CreateDocumentAsync((AzureDocumentDbCollection).SelfLink, data).Result);
         DateTime end = DateTime.Now;
         Logger.LogDebug(string.Format("Adding data in the Azure database took {0} and cost:r\n{1}", end - start, result), "AzureDocumentDbDataStore\\Add");
     }
     finally
     {
         Logger.LogDebug("Adding data to the Azure database... Done", "AzureDocumentDbDataStore\\Add");
     }
 }