コード例 #1
0
        public PaginationExtension <TDataObject> SearchPaginate(int pageSize, int page)
        {
            var entities = Repository.Get(null, x => x.OrderBy(r => r.CreatedDate), false);
            var _objs    = SFactory.ListMappingEntitiesToObjects(entities);

            int Count = entities.Count();

            _objs = _objs.Skip((page - 1) * pageSize).Take(pageSize);
            int totalPages = (int)Math.Ceiling(Count / (double)pageSize);

            int itemEnd   = pageSize * page;
            int itemStart = (itemEnd - pageSize) + 1;

            if (itemEnd > Count)
            {
                itemEnd = Count;
            }

            var msg = string.Format("Showing {0} to {1} of {2} Records | Total Pages: {3}",
                                    itemStart, itemEnd, Count, totalPages);

            var extension = new PaginationExtension <TDataObject>();

            extension.Summary         = Count > 0 ? msg : string.Empty;
            extension.TotalCount      = Count;
            extension.ReturnedList    = _objs;
            extension.StaticPagedList = new StaticPagedList <TDataObject>(_objs, page, pageSize, Count);
            return(extension);
        }
コード例 #2
0
        public IQueryable <TDataObject> GetMany()
        {
            var entities = Repository.Get(null, null, false);
            var _objs    = SFactory.ListMappingEntitiesToObjects(entities);

            return(_objs);
        }