public Task <SearchResult <ProvisioningConfigurationHistoryResult> > SearchHistory(SearchProvisioningHistoryParameter parameter, CancellationToken cancellationToken)
        {
            IQueryable <ProvisioningConfigurationHistory> result = _configurations.SelectMany(c => c.HistoryLst).AsQueryable();

            if (MAPPING_PROVISIONINGHISTORY_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy))
            {
                result = result.InvokeOrderBy(MAPPING_PROVISIONINGHISTORY_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order);
            }

            int totalLength = result.Count();

            result = result.Skip(parameter.StartIndex).Take(parameter.Count);
            return(Task.FromResult(new SearchResult <ProvisioningConfigurationHistoryResult>
            {
                StartIndex = parameter.StartIndex,
                Count = parameter.Count,
                TotalLength = totalLength,
                Content = result.Select(r => ProvisioningConfigurationHistoryResult.ToDto(r)).ToList()
            }));
        }
        public async Task <SearchResult <ProvisioningConfigurationHistoryResult> > SearchHistory(SearchProvisioningHistoryParameter parameter, CancellationToken cancellationToken)
        {
            IQueryable <ProvisioningConfigurationHistory> result = _dbContext.ProvisioningConfigurationHistory;

            if (MAPPING_PROVISIONINGHISTORY_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy))
            {
                result = result.InvokeOrderBy(MAPPING_PROVISIONINGHISTORY_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order);
            }

            int totalLength = await result.CountAsync(cancellationToken);

            result = result.Skip(parameter.StartIndex).Take(parameter.Count);
            ICollection <ProvisioningConfigurationHistory> content = await result.ToListAsync(cancellationToken);

            return(new SearchResult <ProvisioningConfigurationHistoryResult>
            {
                StartIndex = parameter.StartIndex,
                Count = parameter.Count,
                TotalLength = totalLength,
                Content = content.Select(r => ProvisioningConfigurationHistoryResult.ToDto(r)).ToList()
            });
        }
        public async Task <SearchResult <ProvisioningConfigurationHistoryResult> > SearchHistory(SearchProvisioningHistoryParameter parameter, CancellationToken cancellationToken)
        {
            var collection = _dbContext.ProvisioningConfigurationLst.AsQueryable();
            var histories  = collection.SelectMany(c => c.HistoryLst).AsQueryable();

            if (MAPPING_PROVISIONINGHISTORY_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy))
            {
                histories = histories.InvokeOrderBy(MAPPING_PROVISIONINGHISTORY_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order);
            }

            int totalLength = histories.Count();

            histories = histories.Skip(parameter.StartIndex).Take(parameter.Count);
            ICollection <ProvisioningConfigurationHistory> content = await histories.ToMongoListAsync();

            return(new SearchResult <ProvisioningConfigurationHistoryResult>
            {
                StartIndex = parameter.StartIndex,
                Count = parameter.Count,
                TotalLength = totalLength,
                Content = content.Select(r => ProvisioningConfigurationHistoryResult.ToDto(r)).ToList()
            });
        }