|
@@ -615,12 +615,15 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
|
DocumentCollection dataCollection = await InitializeCollection<T>();
|
|
|
List<T> list = await FindByDict<T>(dict);
|
|
|
List<Tuple<string, string>> pkIdTuplesToDelete = new List<Tuple<string, string>>();
|
|
|
+ string PartitionKey = GetPartitionKey<T>();
|
|
|
if (list.IsNotEmpty())
|
|
|
{
|
|
|
foreach (T t in list)
|
|
|
{
|
|
|
+
|
|
|
+ string pkValue = t.GetType().GetProperty(PartitionKey).GetValue(t).ToString();
|
|
|
string id = t.GetType().GetProperty("id").GetValue(t) + "";
|
|
|
- pkIdTuplesToDelete.Add(new Tuple<string, string>(id, id));
|
|
|
+ pkIdTuplesToDelete.Add(new Tuple<string, string>(pkValue, id));
|
|
|
|
|
|
//log4net 日志記錄
|
|
|
string uuidKey = Guid.NewGuid().ToString();
|
|
@@ -637,7 +640,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return null;
|
|
|
+ return list;
|
|
|
}
|
|
|
long totalNumberOfDocumentsDeleted = 0;
|
|
|
double totalRequestUnitsConsumed = 0;
|
|
@@ -646,12 +649,23 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
|
|
|
|
BulkExecutor bulkExecutor = new BulkExecutor(CosmosClient, dataCollection);
|
|
|
await bulkExecutor.InitializeAsync();
|
|
|
- bulkDeleteResponse = await bulkExecutor.BulkDeleteAsync(pkIdTuplesToDelete);
|
|
|
- totalNumberOfDocumentsDeleted = bulkDeleteResponse.NumberOfDocumentsDeleted;
|
|
|
- totalRequestUnitsConsumed = bulkDeleteResponse.TotalRequestUnitsConsumed;
|
|
|
- totalTimeTakenSec = bulkDeleteResponse.TotalTimeTaken.TotalSeconds;
|
|
|
|
|
|
-
|
|
|
+ try
|
|
|
+ {
|
|
|
+ bulkDeleteResponse = await bulkExecutor.BulkDeleteAsync(pkIdTuplesToDelete);
|
|
|
+ totalNumberOfDocumentsDeleted = bulkDeleteResponse.NumberOfDocumentsDeleted;
|
|
|
+ totalRequestUnitsConsumed = bulkDeleteResponse.TotalRequestUnitsConsumed;
|
|
|
+ totalTimeTakenSec = bulkDeleteResponse.TotalTimeTaken.TotalSeconds;
|
|
|
+ }
|
|
|
+ catch (DocumentClientException de)
|
|
|
+ {
|
|
|
+ throw new BizException("Document client exception: {0}"+ de);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ throw new BizException("Exception: "+ e);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return list;
|
|
|
}
|