I have the following method in a class I am using for pagination in my app:
public static PagedList<T> ToPagedList(IEnumerable<T> source, int pageNumber, int pageSize)
{
var count = source.Count();
var items = source
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize).ToList();
return new PagedList<T>(items, count, pageNumber, pageSize);
}
In this method I am passing in a collection of generic objects as IEnumerable<T> source which regardless of type will always have an Id field. What I'd like to do is pull out all of the Ids for these objects and store them in a list to be passed into my PagedList constructor. Is this possible?