|
@@ -144,9 +144,19 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
|
|
|
|
private async Task<DocumentCollection> InitializeCollection<T>()
|
|
|
{
|
|
|
- Type t = typeof(T);
|
|
|
+ Type type = typeof(T);
|
|
|
string partitionKey = GetPartitionKey<T>();
|
|
|
- return await InitializeCollection(t.Name, partitionKey);
|
|
|
+ string CollectionName;
|
|
|
+ IEnumerable<CosmosDBAttribute> attributes = type.GetCustomAttributes<CosmosDBAttribute>(true);
|
|
|
+ if (!string.IsNullOrEmpty(attributes.First<CosmosDBAttribute>().Name))
|
|
|
+ {
|
|
|
+ CollectionName = attributes.First<CosmosDBAttribute>().Name;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CollectionName = type.Name;
|
|
|
+ }
|
|
|
+ return await InitializeCollection(CollectionName, partitionKey);
|
|
|
}
|
|
|
|
|
|
private async Task<DocumentCollection> InitializeCollection(string CollectionName, string PartitionKey)
|