|
@@ -24,6 +24,9 @@ using System.Text;
|
|
using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
|
|
using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Concurrent;
|
|
|
|
+using DataType = Microsoft.Azure.Documents.DataType;
|
|
|
|
+using RequestOptions = Microsoft.Azure.Documents.Client.RequestOptions;
|
|
|
|
+using PartitionKey = Microsoft.Azure.Documents.PartitionKey;
|
|
|
|
|
|
namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
{ /// <summary>
|
|
{ /// <summary>
|
|
@@ -61,12 +64,12 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
}
|
|
}
|
|
Database = options.Database;
|
|
Database = options.Database;
|
|
CollectionThroughput = options.CollectionThroughput;
|
|
CollectionThroughput = options.CollectionThroughput;
|
|
- CosmosClient.CreateDatabaseIfNotExistsAsync(new Database { Id = Database });
|
|
|
|
|
|
+ CosmosClient.CreateDatabaseIfNotExistsAsync(new Microsoft.Azure.Documents.Database { Id = Database });
|
|
// _connectionString = options.ConnectionString;
|
|
// _connectionString = options.ConnectionString;
|
|
- // CosmosSerializer
|
|
|
|
|
|
+ // CosmosSerializer
|
|
|
|
|
|
//获取数据库所有的表
|
|
//获取数据库所有的表
|
|
- FeedResponse<DocumentCollection> collections = CosmosClient.ReadDocumentCollectionFeedAsync(UriFactory.CreateDatabaseUri(Database)).GetAwaiter().GetResult();
|
|
|
|
|
|
+ Microsoft.Azure.Documents.Client.FeedResponse<DocumentCollection> collections = CosmosClient.ReadDocumentCollectionFeedAsync(UriFactory.CreateDatabaseUri(Database)).GetAwaiter().GetResult();
|
|
foreach (IGrouping<string, DocumentCollection> group in collections.GroupBy(c => c.Id))
|
|
foreach (IGrouping<string, DocumentCollection> group in collections.GroupBy(c => c.Id))
|
|
{
|
|
{
|
|
DocumentCollectionDict.TryAdd(group.Key, group.First());
|
|
DocumentCollectionDict.TryAdd(group.Key, group.First());
|
|
@@ -109,7 +112,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
else
|
|
else
|
|
{
|
|
{
|
|
DocumentCollection collectionDefinition = new DocumentCollection { Id = CollectionName };
|
|
DocumentCollection collectionDefinition = new DocumentCollection { Id = CollectionName };
|
|
- collectionDefinition.IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 });
|
|
|
|
|
|
+ collectionDefinition.IndexingPolicy = new Microsoft.Azure.Documents.IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 });
|
|
|
|
|
|
// collectionDefinition.PartitionKey = new PartitionKeyDefinition { Paths = new System.Collections.ObjectModel.Collection<string>() };
|
|
// collectionDefinition.PartitionKey = new PartitionKeyDefinition { Paths = new System.Collections.ObjectModel.Collection<string>() };
|
|
if (!string.IsNullOrEmpty(PartitionKey))
|
|
if (!string.IsNullOrEmpty(PartitionKey))
|
|
@@ -122,7 +125,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
CollectionThroughput = RU;
|
|
CollectionThroughput = RU;
|
|
}
|
|
}
|
|
DocumentCollection DocumentCollection = CosmosClient.CreateDocumentCollectionIfNotExistsAsync(
|
|
DocumentCollection DocumentCollection = CosmosClient.CreateDocumentCollectionIfNotExistsAsync(
|
|
- UriFactory.CreateDatabaseUri(Database), collectionDefinition, new RequestOptions { OfferThroughput = CollectionThroughput }).GetAwaiter().GetResult();
|
|
|
|
|
|
+ UriFactory.CreateDatabaseUri(Database), collectionDefinition, new Microsoft.Azure.Documents.Client.RequestOptions { OfferThroughput = CollectionThroughput }).GetAwaiter().GetResult();
|
|
DocumentCollectionDict.TryAdd(CollectionName, DocumentCollection);
|
|
DocumentCollectionDict.TryAdd(CollectionName, DocumentCollection);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -171,7 +174,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
else
|
|
else
|
|
{
|
|
{
|
|
DocumentCollection documentCollection = new DocumentCollection { Id = CollectionName };
|
|
DocumentCollection documentCollection = new DocumentCollection { Id = CollectionName };
|
|
- documentCollection.IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 });
|
|
|
|
|
|
+ documentCollection.IndexingPolicy = new Microsoft.Azure.Documents.IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 });
|
|
|
|
|
|
// collectionDefinition.PartitionKey = new PartitionKeyDefinition { Paths = new System.Collections.ObjectModel.Collection<string>() };
|
|
// collectionDefinition.PartitionKey = new PartitionKeyDefinition { Paths = new System.Collections.ObjectModel.Collection<string>() };
|
|
if (!string.IsNullOrEmpty(PartitionKey))
|
|
if (!string.IsNullOrEmpty(PartitionKey))
|
|
@@ -640,7 +643,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
- public async Task<List<T>> FindByDict<T>(Dictionary<string, object> dict, bool IsPk)
|
|
|
|
|
|
+ public async Task<List<T>> FindByDict<T>(Dictionary<string, object> dict, bool IsPk=true)
|
|
{
|
|
{
|
|
Type t = typeof(T);
|
|
Type t = typeof(T);
|
|
// List<T> objs = new List<T>();
|
|
// List<T> objs = new List<T>();
|