private PageResult <DM> ToPageResult1 <DM>(PageOptions options, IQueryable <DM> models) { options.EnsureValid(typeof(DM), typeof(DM).Name, MaxResults); var data = models.Skip((options.Page.Value - 1) * options.Count.Value); bool next = data.Count() > options.Count.Value; var arr = data.Take(options.Count.Value); return(new PageResult <DM>() { Data = arr, HasMorePages = next, Page = options.Page.Value, Count = options.Count.Value }); }
public virtual PageResult <T> ToPageResult <T, DM>(PageOptions options, IQueryable <DM> models) where T : IPageResultModel <T, DM>, new() { options.EnsureValid(typeof(DM), typeof(DM).Name, MaxResults); var data = models.Skip((options.Page.Value - 1) * options.Count.Value); bool next = data.Count() > options.Count.Value; var arr = new List <T>(); foreach (var mdl in data.Take(options.Count.Value)) { arr.Add(new T().Map(mdl)); } return(new PageResult <T>() { Data = arr, HasMorePages = next, Page = options.Page.Value, Count = options.Count.Value }); }