|
@@ -14,6 +14,7 @@ using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using TEAMModelOS.SDK.Context.Attributes.Azure;
|
|
using TEAMModelOS.SDK.Context.Attributes.Azure;
|
|
using TEAMModelOS.SDK.Context.Exception;
|
|
using TEAMModelOS.SDK.Context.Exception;
|
|
|
|
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
|
|
using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
|
|
using TEAMModelOS.SDK.Module.AzureCosmosDB.Configuration;
|
|
using TEAMModelOS.SDK.Module.AzureCosmosDB.Configuration;
|
|
|
|
|
|
@@ -331,10 +332,14 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDBV3
|
|
// return response.Resource;
|
|
// return response.Resource;
|
|
//}
|
|
//}
|
|
|
|
|
|
- public async Task<List<T>> FindAll<T>() where T : ID
|
|
|
|
|
|
+ public async Task<List<T>> FindAll<T>(List<string> propertys = null) where T : ID
|
|
{
|
|
{
|
|
Container container = await InitializeCollection<T>();
|
|
Container container = await InitializeCollection<T>();
|
|
- return await ResultsFromFeedIterator(container.GetItemQueryIterator<T>());
|
|
|
|
|
|
+ StringBuilder sql;
|
|
|
|
+ sql = SQLHelperParametric.GetSQLSelect(propertys);
|
|
|
|
+ CosmosDbQuery cosmosDbQuery = new CosmosDbQuery {QueryText = sql.ToString() };
|
|
|
|
+ FeedIterator<T> query = container.GetItemQueryIterator<T>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition);
|
|
|
|
+ return await ResultsFromFeedIterator(query);
|
|
|
|
|
|
}
|
|
}
|
|
private async Task<List<T>> ResultsFromFeedIterator<T>(FeedIterator<T> query, int? maxItemCount = null)
|
|
private async Task<List<T>> ResultsFromFeedIterator<T>(FeedIterator<T> query, int? maxItemCount = null)
|
|
@@ -375,7 +380,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDBV3
|
|
|
|
|
|
return results;
|
|
return results;
|
|
}
|
|
}
|
|
- public async Task<List<dynamic>> FindByDict(string CollectionName, Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null)
|
|
|
|
|
|
+ public async Task<List<dynamic>> FindByDict(string CollectionName, Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null, List<string> propertys = null)
|
|
{
|
|
{
|
|
if (DocumentCollectionDict.TryGetValue(CollectionName, out Container container))
|
|
if (DocumentCollectionDict.TryGetValue(CollectionName, out Container container))
|
|
{
|
|
{
|
|
@@ -386,7 +391,8 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDBV3
|
|
// QueryText = sql.ToString()
|
|
// QueryText = sql.ToString()
|
|
|
|
|
|
//};
|
|
//};
|
|
- StringBuilder sql = new StringBuilder("select value(c) from c");
|
|
|
|
|
|
+ StringBuilder sql;
|
|
|
|
+ sql = SQLHelperParametric.GetSQLSelect(propertys);
|
|
CosmosDbQuery cosmosDbQuery = SQLHelperParametric.GetSQL(dict, sql);
|
|
CosmosDbQuery cosmosDbQuery = SQLHelperParametric.GetSQL(dict, sql);
|
|
QueryRequestOptions queryRequestOptions = GetDefaultQueryRequestOptions(itemsPerPage: GetEffectivePageSize(itemsPerPage, maxItemCount));
|
|
QueryRequestOptions queryRequestOptions = GetDefaultQueryRequestOptions(itemsPerPage: GetEffectivePageSize(itemsPerPage, maxItemCount));
|
|
FeedIterator<dynamic> query = container.GetItemQueryIterator<dynamic>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: queryRequestOptions);
|
|
FeedIterator<dynamic> query = container.GetItemQueryIterator<dynamic>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: queryRequestOptions);
|
|
@@ -422,18 +428,20 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDBV3
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public async Task<List<T>> FindByParams<T>(Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null) where T : ID
|
|
|
|
|
|
+ public async Task<List<T>> FindByParams<T>(Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null, List<string> propertys = null) where T : ID
|
|
{
|
|
{
|
|
- return await FindByDict<T>(dict, itemsPerPage, maxItemCount, partitionKey);
|
|
|
|
|
|
+ return await FindByDict<T>(dict, itemsPerPage, maxItemCount, partitionKey, propertys);
|
|
}
|
|
}
|
|
- public async Task<List<T>> FindByDict<T>(Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null) where T : ID
|
|
|
|
|
|
+ public async Task<List<T>> FindByDict<T>(Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null,List<string> propertys = null) where T : ID
|
|
{
|
|
{
|
|
|
|
+ StringBuilder sql;
|
|
|
|
+ sql = SQLHelperParametric.GetSQLSelect(propertys);
|
|
|
|
|
|
- StringBuilder sql = new StringBuilder("select value(c) from c");
|
|
|
|
CosmosDbQuery cosmosDbQuery = SQLHelperParametric.GetSQL(dict, sql);
|
|
CosmosDbQuery cosmosDbQuery = SQLHelperParametric.GetSQL(dict, sql);
|
|
QueryRequestOptions queryRequestOptions = GetDefaultQueryRequestOptions(itemsPerPage: GetEffectivePageSize(itemsPerPage, maxItemCount));
|
|
QueryRequestOptions queryRequestOptions = GetDefaultQueryRequestOptions(itemsPerPage: GetEffectivePageSize(itemsPerPage, maxItemCount));
|
|
return await ResultsFromQueryAndOptions<T>(cosmosDbQuery, queryRequestOptions);
|
|
return await ResultsFromQueryAndOptions<T>(cosmosDbQuery, queryRequestOptions);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
private async Task<List<T>> ResultsFromQueryAndOptions<T>(CosmosDbQuery cosmosDbQuery, QueryRequestOptions queryOptions, int? maxItemCount = null)
|
|
private async Task<List<T>> ResultsFromQueryAndOptions<T>(CosmosDbQuery cosmosDbQuery, QueryRequestOptions queryOptions, int? maxItemCount = null)
|
|
{
|
|
{
|