Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        public virtual IPage <TARGET> LoadPage <SOURCE, TARGET, T1>(IQuery <T1, SOURCE> query, Pageable pageable, IModelConverter <SOURCE, TARGET> converter)
        {
            int            firstResult = (pageable.PageNo <= 0 ? 0 : pageable.PageNo - 1) * pageable.PageSize;
            IList <SOURCE> elements    = query.ListPage(firstResult, pageable.PageSize);
            long           count       = query.Count();

            return(new PageImpl <TARGET>(converter.From(elements), count));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        public virtual IEnumerable <TARGET> From <SOURCE, TARGET>(IEnumerable <SOURCE> sourceElements, IModelConverter <SOURCE, TARGET> elementConverter)
        {
            IList <TARGET> targetElements = new List <TARGET>();

            foreach (SOURCE sourceElement in sourceElements)
            {
                targetElements.Add(elementConverter.From(sourceElement));
            }
            return(targetElements);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        public virtual IPage <TARGET> LoadPage <SOURCE, TARGET, T1>(ServiceImpl service,
                                                                    IQuery <T1, SOURCE> query,
                                                                    Pageable pageable,
                                                                    IModelConverter <SOURCE, TARGET> converter,
                                                                    Func <IQuery <T1, SOURCE>, int, int, PageQueryCmd <T1, SOURCE> > createPageQueryCmd)
        {
            int firstResult = (pageable.PageNo <= 0 ? 0 : pageable.PageNo - 1) * pageable.PageSize;

            PageQueryCmd <T1, SOURCE> cmd;

            if (createPageQueryCmd != null)
            {
                cmd = createPageQueryCmd(query, firstResult, pageable.PageSize);
            }
            else
            {
                cmd = new PageQueryCmd <T1, SOURCE>(query, firstResult, pageable.PageSize);
            }
            var  elements = service.CommandExecutor.Execute(cmd);
            long count    = query.Count();

            return(new PageImpl <TARGET>(converter.From(elements), count));
        }