EF分页

public List<SongList> SongLists(int pageIndex, int pageSize, out int totaPage)
{
var quaryable = Dataslot.MusicContexts.SongList.AsQueryable();
quaryable = quaryable.Where(m => m.Slid != 0);
int totalCount = quaryable.Count();
var mylist = quaryable.OrderBy(m => m.Slid).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
//获取分页后的总条数
totaPage = (totalCount - 1) / pageSize + 1;
return mylist;
}

posted @ 2019-12-05 20:13  噬堕  阅读(521)  评论(0编辑  收藏  举报