SaaS CMS has officially launched! Learn more now.

Pagination not working with Find



I am using Find and implementing pagination as well for search. But my result set always returns 25 instead of showing 6 results in each page. Could anyone please have a look at my code below and point out what I need to do differently.

int pageSize = 6;
int pageNumber = (page ?? 1);
IClient client = SearchClient.Instance;
var model = new SearchViewModel(currentPage, q);
if (String.IsNullOrEmpty(q))
return View(model);

var searchResults = client.Search().For(q).Select(x => new ArticleListViewModel
ArticleCategory = x.ArticleCategory,
Created = x.Created,
PageTitle = x.PageTitle,
ArticleImage = x.ArticleImage,
ArticleLink = x.ExternalURL,
Author = Helper.GetAuthorName(x.Author),
Link = Helper.GetInfoPage(x.Author),
}).Skip((pageNumber - 1) * pageSize).Take(25).GetResult();

Mar 23, 2018 15:44


Mar 23, 2018 15:55

Hey Aniket, thanks for looking into this. But Take will just mention how many results to pull. In that case it will only pull 6 as per my knowledge, which would then prevent the pagination part.

Edited, Mar 23, 2018 16:03

In your code, you have it hardcoded to 25 change that to Take(pageSize)

Mar 23, 2018 16:05

Thanks Aniket :)

Mar 23, 2018 16:23
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.