entity framework pagination Edit

Murugan Andezuthu Dharmaratnam | 01 September 2020 | 596

entity framework paging

Sample Code

var total = setupcountry.Select(p => p.Phrase).Count();
var pageSize = 10; // set your page size, which is number of records per page

var page = 1; // set current page number, must be >= 1

var skip = pageSize * (page-1);

var canPage = skip < total;

if (canPage) // do what you wish if you can page no further
   return;

Phrases = setupcountry.Select(p => p.Phrase)
             .Skip(skip)
             .Take(pageSize)
             .ToArray();