Phân trang bằng LINQ trong ASP.NET

 

public List<UserInfo> GetByPageLinq(int pageSize, int pageNum, out int totalRowCount)
{
    List<UserInfo> temp = GetAll();
    var query = from c in temp
                orderby c.UserID ascending
                select c;
    totalRowCount = temp.Count;
    var list = query.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList();
    return list;
}