|
@@ -25,7 +25,7 @@ using TEAMModelOS.SDK.Models;
|
|
|
namespace TEAMModelOS.SDK.DI
|
|
|
{
|
|
|
public static class AzureCosmosExtensions
|
|
|
- {
|
|
|
+ {
|
|
|
public static double RU(this Response response)
|
|
|
{
|
|
|
try
|
|
@@ -53,6 +53,13 @@ namespace TEAMModelOS.SDK.DI
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 取得当前容器指定分区键的Count数,支持SQL Where条件,不支持排序
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="container"></param>
|
|
|
+ /// <param name="partitionkey"></param>
|
|
|
+ /// <param name="queryWhere"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public static async Task<int> GetCount(this CosmosContainer container, string partitionkey, string queryWhere = "WHERE 1=1")
|
|
|
{
|
|
|
int totalCount = 0;
|
|
@@ -71,5 +78,41 @@ namespace TEAMModelOS.SDK.DI
|
|
|
}
|
|
|
return totalCount;
|
|
|
}
|
|
|
+
|
|
|
+ public static async Task<List<Response>> DeleteItemsStreamAsync(this CosmosContainer container, List<string> ids, string partitionkey )
|
|
|
+ {
|
|
|
+ List<Response> responses = new List<Response>();
|
|
|
+
|
|
|
+ foreach (var id in ids)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ responses.Add(await container.DeleteItemStreamAsync(id, new PartitionKey(partitionkey)));
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return responses;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static async Task<List<ItemResponse<T>>> DeleteItemsAsync<T>(this CosmosContainer container, List<string> ids, string partitionkey)
|
|
|
+ {
|
|
|
+ List<ItemResponse<T>> responses = new List<ItemResponse<T>>();
|
|
|
+
|
|
|
+ foreach (var id in ids)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ responses.Add(await container.DeleteItemAsync<T>(id, new PartitionKey(partitionkey)));
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return responses;
|
|
|
+ }
|
|
|
}
|
|
|
}
|