i’ve define static class to enable paging :
public static class Pager
{
public static IEnumerable<T> PageData<T>(this IEnumerable<T> source, int currentPage, int pageSize)
{
var sourceCopy = source.ToList();
if (sourceCopy.Count() < pageSize)
{
return sourceCopy;
}
return sourceCopy.Skip((currentPage - 1) * pageSize).Take(pageSize);
}
}
and i want in my controller to do like :
var pagedDataCourses = products.OrderBy(p => p.productName).PageData(currentPage, pageSize);
so where i can put that static class/method so i can get extension method for paging in all controller.
You will have to put it in the same namespace as where you are using the extension. Or us the “using” at the top of your .cs files