Example #1
0
        public override async Task <QueryStatistic> Statistic(TQuery query, CancellationToken cancellationToken = default)
        {
            query.Pagination = null;
            if (await EfficientStatistic(query, cancellationToken) is QueryStatistic res)
            {
                return(res);
            }
            var result = new QueryStatistic
            {
                Count = await Query(query, cancellationToken).CountAsync(cancellationToken).ConfigureAwait(false)
            };

            return(result);
        }
Example #2
0
        protected virtual async Task BuildDataIdList(IList <TId> dataIds, string rootPath)
        {
            {
                var stats = new QueryStatistic
                {
                    Count = dataIds.Count
                };
                await using var st = FSStaticBuilder.GetFileRewriteStream(Paths.GetStatisticFile(rootPath));
                await JsonSerializer.SerializeAsync(st, stats).ConfigureAwait(false);
            }

            {
                await using var st = FSStaticBuilder.GetFileRewriteStream(Paths.GetIdListFile(rootPath));
                await JsonSerializer.SerializeAsync(st, dataIds).ConfigureAwait(false);
            }
        }
Example #3
0
        public static PagingData <T> AsPagingData <T>(this IEnumerable <T> data, QueryRequest query, QueryStatistic statistic)
        {
            Pagination pagination = new Pagination
            {
                TotalCount = statistic.Count
            };

            if (query.Pagination is not null)
            {
                pagination.CurrentPage = query.Pagination.CurrentPage;
                pagination.PageSize    = query.Pagination.PageSize;
            }
            else
            {
                pagination.CurrentPage = 0;
                pagination.PageSize    = pagination.TotalCount;
            }

            return(new PagingData <T>(data, pagination));
        }
Example #4
0
 public static async Task <PagingData <T> > AsPagingData <T>(this IAsyncEnumerable <T> data, QueryRequest query, QueryStatistic statistic)
 {
     return((await data.ToArrayAsync().ConfigureAwait(false)).AsPagingData(query, statistic));
 }
Example #5
0
 public virtual Task <QueryStatistic> Statistic(TQuery query, CancellationToken cancellationToken = default) => Task.FromResult(QueryStatistic.Empty());