日期:2014-05-20 浏览次数:20733 次
public static List<User> PageUser(int pageIndex, int pageSize, out int count) { var query = (from User in entities.User orderby User.Id descending select User).Skip((pageIndex-1)*pageSize).Take(pageSize); count = entities.User.Count(); return query.ToList(); }
public List<TEntity> Page<TEntity>(string keys, int pageIndex, int pageSize, out int count) where TEntity : EntityObject { using (var ctx = new XXXEntities()) { var es = ctx.CreateObjectSet<TEntity>(); count = es.Count(); var query = es.OrderBy(keys).Skip((pageIndex - 1) * pageSize).Take(pageSize); return query.ToList(); } }