コード例 #1
0
 /// <summary>
 /// 转换为可分页集合(注:需要对查询接口进行排序操作,否则 LINQ 会抛出未排序异常)。
 /// </summary>
 /// <typeparam name="TEntity">指定的实体类型。</typeparam>
 /// <param name="orderedQuery">给定的 <see cref="IOrderedQueryable{TEntity}"/>。</param>
 /// <param name="skip">给定的跳过条数。</param>
 /// <param name="take">给定的获取条数。</param>
 /// <param name="cancellationToken">给定的 <see cref="CancellationToken"/>。</param>
 /// <returns>返回一个包含 <see cref="IPageable{TEntity}"/> 的异步操作。</returns>
 public static ValueTask <IPageable <TEntity> > AsPagingBySkipAsync <TEntity>(this IOrderedQueryable <TEntity> orderedQuery,
                                                                              int skip, int take, CancellationToken cancellationToken = default)
     where TEntity : class
 => orderedQuery.AsPagingAsync(paging => paging.ComputeBySkip(skip, take), cancellationToken);
コード例 #2
0
 /// <summary>
 /// 转换为可分页集合(注:需要对查询接口进行排序操作,否则 LINQ 会抛出未排序异常)。
 /// </summary>
 /// <typeparam name="TEntity">指定的实体类型。</typeparam>
 /// <param name="orderedQuery">给定的 <see cref="IOrderedQueryable{TEntity}"/>。</param>
 /// <param name="index">给定的页索引。</param>
 /// <param name="size">给定的页大小。</param>
 /// <param name="cancellationToken">给定的 <see cref="CancellationToken"/>。</param>
 /// <returns>返回一个包含 <see cref="IPageable{TEntity}"/> 的异步操作。</returns>
 public static ValueTask <IPageable <TEntity> > AsPagingByIndexAsync <TEntity>(this IOrderedQueryable <TEntity> orderedQuery,
                                                                               int index, int size, CancellationToken cancellationToken = default)
     where TEntity : class
 => orderedQuery.AsPagingAsync(paging => paging.ComputeByIndex(index, size), cancellationToken);