public IEnumerable <Models.Comment> GetCommentsPage(long postId, int page, int onPage) { if (page > GetCommentsPageCount(postId, onPage)) { return(null); } return(DbSet_ .Where(x => x.PostId == postId) .OrderByDescending(x => x.PostingTime) .Skip(onPage * (page - 1)).Take(onPage) .ToList()); }
public int GetCommentsPageCount(long postId, int onPage) { int count = DbSet_.Where(x => x.PostId == postId).Count(); return(count / onPage + (count % onPage == 0 ? 0 : 1)); }