Exemplo n.º 1
0
        /// <summary>
        ///     Returns a pager which allows entities to be paged.
        /// </summary>
        /// <param name="sortSelector"> Required sorting criteria. </param>
        /// <param name="pageSize"> The desired page size. </param>
        /// <param name="predicate"> Optional predicate to filter the paged entities. </param>
        /// <param name="fetchOptions">Optional delegate to specify additional fetching options.</param>
        /// <returns>
        ///     <see cref="IPager{T}" /> which allows the entities to be paged.
        /// </returns>
        public IPager <T> Pager(ISortSelector sortSelector, int pageSize, Expression <Func <T, bool> > predicate = null,
                                Action <IFetchOptions <T> > fetchOptions = null)
        {
            if (sortSelector == null)
            {
                throw new ArgumentNullException("sortSelector");
            }

            var query = GetFindQuery(predicate, null, fetchOptions);

            return(new Pager <T>(query, sortSelector, pageSize));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Returns a pager which allows shaped entities to be paged.
        /// </summary>
        /// <param name="selector"> The selector used to shape the entities. </param>
        /// <param name="pageSize"> The desired page size. </param>
        /// <param name="sortSelector"> Required sorting criteria. </param>
        /// <param name="predicate"> Optional predicate to filter the paged entities. </param>
        /// <param name="fetchOptions">Optional delegate to specify additional fetching options.</param>
        /// <typeparam name="TResult"> The shape of the result. </typeparam>
        /// <returns>
        ///     <see cref="IPager{T}" /> which allows the shaped entities to be paged.
        /// </returns>
        public IPager <TResult> Pager <TResult>(Func <IQueryable <T>, IQueryable <TResult> > selector, int pageSize,
                                                ISortSelector sortSelector, Expression <Func <T, bool> > predicate = null,
                                                Action <IFetchOptions <TResult> > fetchOptions = null)
        {
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }
            if (sortSelector == null)
            {
                throw new ArgumentNullException("sortSelector");
            }

            var query = GetFindQuery(selector, predicate, null, fetchOptions);

            // If TResult is not an entity type, then the query strategy must be set to DataSourceOnly
            // otherwise the EntityQueryPager doesn't return any data. This appears to be a bug in DevForce.
            if (!EntityManager.IsEntityType(typeof(TResult)))
            {
                query = query.With(QueryStrategy.DataSourceOnly);
            }

            return(new Pager <TResult>(query, sortSelector, pageSize));
        }
Exemplo n.º 3
0
 public Pager(IEntityQuery <T> baseQuery, ISortSelector sortSelector, int pageSize)
 {
     _entityQueryPager = EntityQueryPager.Create(baseQuery, sortSelector, pageSize);
 }