public async Task<PaginationResult<TypeEntity>> GetAllWorkFlowAsync(string filterCondition,string sort, int page, uint? limit, bool includeDeleted, string model)
{
var sharedResult = _mongoRepository
.GetAllAsync(SharedDbQueryableCollection.Where(td => model == null || td.Model == model).ApplyFilter(filterCondition, _scopeConditionEnforcement));
var tenantResult = _mongoRepository
.GetAllAsync(TenantDbQueryableCollection.Where(td => model == null || td.Model == model).ShouldIncludeDeleted(includeDeleted)
.ApplyFilter(filterCondition, _scopeConditionEnforcement));
var result = (await Task.WhenAll(sharedResult, tenantResult))
.SelectMany(t => t).ToList();
var finalResult = result
.Join(WorkFlowDbQueryableCollection,
main => main.Id,
workflow => workflow.Id,
(main, workflow) => new TypeEntity(main.TypeId, main.Version.ToString())
{
Id = main.Id,
Model = main.Model,
Body = main.Body,
Version = main.Version,
WorkFlowStatus = workflow.Body
})
.ToList();
var paginationInput = MongoQueryableExtension.CreatePaginationInput<TypeDefinitionEntity>(sort, page, limit);
var paginatedResult = PaginateTypeDefinition<TypeDefinitionEntity>(finalResult, paginationInput);
return paginatedResult;
}
Above is the code for an API which combines the result from multiple collections on Id match. This API is taking 13 sec and by using timestamp I came to know that this part is taking more time.
Any suggestions how can i reduce response time.