public Builder() { _query = new PageQuery <TEntity> { Predicate = s => true }; }
public static IPaged <T> GetPagedBuiltByParameters( IQueryable <T> sourceQuery, IPageQuery pageQuery, string[] defaultSortKeys) { return(sourceQuery .ToPaged(pageQuery, defaultSortKeys.ToArray())); }
public static async Task <IPaged <T> > GetPagedBuiltByParametersAsync( IQueryable <T> sourceQuery, Func <IQueryable <T>, CancellationToken, Task <List <T> > > toListAsync, IPageQuery pageQuery, string[] defaultSortKeys, CancellationToken ctok) { return(await sourceQuery.ToPagedAsync(toListAsync, pageQuery, defaultSortKeys.ToArray(), ctok)); }
public static IPaged <TResult> GetPagedBuiltByParameters <TResult>( IQueryable <T> sourceQuery, Expression <Func <T, TResult> > selector, IPageQuery pageQuery, string[] defaultSortKeys) where TResult : class { return(sourceQuery .ToPaged(selector, pageQuery, defaultSortKeys.ToArray())); }
/// <summary> /// Gets the paged list. /// </summary> /// <param name="query">查询</param> /// <returns>PagedList<TaskQueue>.</returns> /// <exception cref="ArgumentNullException">query</exception> public PagedList <TaskQueue> GetPagedList(IPageQuery <TaskQueue> query) { if (query == null) { throw new ArgumentNullException(nameof(query)); } return(null); // return Repository<ITaskQueueRepository>().GetPage(query); }
public static Page <T> ToPage <T>(this IOrderedQueryable <T> list, IPageQuery query) { var count = list.Count(); var items = list.Skip(query.Skip).Take(query.Take).ToList(); return(new Page <T>() { Items = items, Count = count }); }
public async Task <IPageResult <TEntity> > PagingAsync(IPageQuery <TEntity> query, CancellationToken cancellationToken = default(CancellationToken)) { var data = await Set.AsNoTracking() .Where(query.Predicate) .OrderBy($"{query.OrderBy} {(query.IsDesc ? "desc" : "asc")}") .Skip(query.Skip) .Take(query.Take) .ToListAsync(cancellationToken); return(new PageResult <TEntity> .Builder(data) .CurrentPage(query.CurrentPage) .PageSize(query.PageSize) .TotalCount(await CountAsync(query.Predicate, cancellationToken)) .Build()); }
public IPageResult <TEntity> Paging(IPageQuery <TEntity> query) { var data = Set.AsNoTracking() .Where(query.Predicate) .OrderBy($"{query.OrderBy} {(query.IsDesc ? "desc" : "asc")}") .Skip(query.Skip) .Take(query.Take) .ToList(); return(new PageResult <TEntity> .Builder(data) .CurrentPage(query.CurrentPage) .PageSize(query.PageSize) .TotalCount(Count(query.Predicate)) .Build()); }
public PagedList <TEntity> GetPagedList(IPageQuery <TEntity> queryCriteria) { var query = UnitOfWork.Set <TEntity>(); if (queryCriteria == null) { return(PagedList <TEntity> .Create(query.ToList(), query.Count(), query.Count(), 1)); } var count = queryCriteria.ExecuteCountQuery(query); var queryResult = queryCriteria.Execute(query); var resultList = queryResult.ToList(); resultList.ForEach(r => { r = JsonMapping.ConvertToExtension(r); }); return(PagedList <TEntity> .Create(resultList, count, queryCriteria.PageSize, queryCriteria.PageIndex)); }
internal static IPaged <T> ToPaged <T>( this IQueryable <T> queryable, IPageQuery pageQuery, string[] defaultSortKeys) where T : class { var pagedIQueryable = queryable.GetPerPageIQueryable(pageQuery, defaultSortKeys, out var totalItemsCount); var items = pagedIQueryable.ToList(); var result = new Paged <T>( items, pageQuery.PageIndex, pageQuery.PageSize, pageQuery.IndexFrom, totalItemsCount); return(result); }
internal static IQueryable <T> GetPerPageIQueryable <T>( this IQueryable <T> queryable, IPageQuery pageQuery, string[] defaultSortKeys, out int totalItems) where T : class { if (pageQuery == null) { throw new ArgumentNullException(nameof(pageQuery)); } if (!string.IsNullOrWhiteSpace(pageQuery.Keyword)) { queryable = queryable.WhereByKeyword( pageQuery.Keyword, pageQuery.SearchFields.Pascalize()); } totalItems = queryable.Count(); var pageSize = PageQuery.DefaultPageSize; var pageIndex = pageQuery.IndexFrom.Id; if (pageQuery.PageSize > 0) { pageSize = pageQuery.PageSize > PageQuery.MaxPageSize ? PageQuery.MaxPageSize : pageQuery.PageSize; } if (pageQuery.PageIndex > pageQuery.IndexFrom) { pageIndex = pageQuery.PageIndex; } if (pageQuery.Sorts != null && IsValidSorts <T>(pageQuery.Sorts)) { queryable = queryable.ApplySorting(pageQuery.Sorts); } else { if (defaultSortKeys.Any()) { queryable = queryable.OrderBy(string.Join(",", defaultSortKeys)); } } var result = queryable.Skip((pageIndex - pageQuery.IndexFrom.Id) * pageSize) .Take(pageSize); return(result); }
internal static IPaged <T> ToPaged <T>( this IQueryable <T> queryable, IPageQuery pageQuery, string[] defaultSortKeys) where T : class { var pagedIQueryable = queryable.GetPerPageIQueryable(pageQuery, defaultSortKeys, out var totalItemsCount); var items = pagedIQueryable.ToList(); return(new Paged <T>( items, ObjectDictionaryHelpers.GetPublicPropertyNames <T>(), defaultSortKeys, totalItemsCount, pageQuery.PageIndex, pageQuery.PageSize, pageQuery.IndexFrom, true)); }
internal static async Task <IPaged <T> > ToPagedAsync <T>( this IQueryable <T> queryable, IPageQuery pageQuery, string[] defaultSortKeys, CancellationToken ctok = default) where T : class { var pagedIQueryable = queryable.GetPerPageIQueryable(pageQuery, defaultSortKeys, out var totalItemsCount); var items = await pagedIQueryable.ResolvedToListAsync(ctok); var result = new Paged <T>( items, pageQuery.PageIndex, pageQuery.PageSize, pageQuery.IndexFrom, totalItemsCount); return(result); }
internal static async Task <IPaged <T> > ToPagedAsync <T>( this IQueryable <T> queryable, Func <IQueryable <T>, CancellationToken, Task <List <T> > > toListAsync, IPageQuery pageQuery, string[] defaultSortKeys, CancellationToken ctok = default) where T : class { var pagedIQueryable = queryable.GetPerPageIQueryable(pageQuery, defaultSortKeys, out var totalItemsCount); var items = await toListAsync(pagedIQueryable, ctok); return(new Paged <T>( items, ObjectDictionaryHelpers.GetPublicPropertyNames <T>(), defaultSortKeys, totalItemsCount, pageQuery.PageIndex, pageQuery.PageSize, pageQuery.IndexFrom, true)); }
public static IQueryable <T> TakePageResult <T>(this IQueryable <T> query, IPageQuery pageData) { if (query == null) { throw new ArgumentNullException(nameof(query)); } if (pageData == null) { throw new ArgumentNullException(nameof(pageData)); } if (pageData.PageNr <= 0) { throw new ArgumentException(nameof(IPageQuery.PageNr) + " should be equal and greater than 1."); } if (pageData.PageSize <= 0) { throw new ArgumentException("Invalid page size."); } return(query.Skip((pageData.PageNr - 1) * pageData.PageSize).Take(pageData.PageSize)); }
public Task <PagedList <TEntity> > GetPagedListAsync(IPageQuery <TEntity> query) { throw new NotImplementedException(); }
/// <summary> /// Create new instance of <see cref="SelectAndPageQuery"/> /// </summary> /// <param name="selectQuery">Select query.</param> /// <param name="pageQuery">Page query.</param> public SelectAndPageQuery(ISelectQuery selectQuery, IPageQuery pageQuery) : base(new IQuery[] { selectQuery, pageQuery }) { }
public async Task <IPageResult <IdS4IdentityResource> > SearchAsync(IPageQuery <IdS4IdentityResource> query) { return(await _identityResourceRepository.PagingAsync(query)); }
public PagedList <TEntity> GetPagedList(IPageQuery <TEntity> queryCriteria) { var predicate = queryCriteria.BuildExpression(); return(GetPagedList(predicate, queryCriteria.PageSize, queryCriteria.PageIndex)); }
public PageLink(IPageQuery pageQuery, string text) { PageQuery = pageQuery; Text = text; }
public static int Skip <T>(this IPageQuery <T> query) => (query.Page - 1) * query.PageSize;
public static int Take <T>(this IPageQuery <T> query) => query.PageSize;
/// <summary> /// Create new instance of <see cref="FilterAndPageQuery"/> /// </summary> /// <param name="filterQuery">Filter query.</param> /// <param name="pageQuery">Page query.</param> public FilterAndPageQuery(IFilterQuery filterQuery, IPageQuery pageQuery) : base(new IQuery[] { filterQuery, pageQuery }) { }
public async Task <IPageResult <Log> > PagingAsync(IPageQuery <Log> query) { return(await _logRepository.PagingAsync(query)); }
public PagedList <TEntity> GetPagedList(IPageQuery <TEntity> query) { return(Store.GetPagedList(query)); }