List<T> 分页方式,泛型分页方式
2011-07-26 10:51
323 查看
List
protected List<T> ListPager<T>(List<T> DataSource, int CurrentPageIndex, int PageSize, string FilterExpression, ref int count) { count = 0; if (DataSource == null || DataSource.Count == 0) return DataSource; count = DataSource.Count; if (string.IsNullOrEmpty(FilterExpression)) { int startIndex = CurrentPageIndex * PageSize; if (startIndex + PageSize > DataSource.Count) { PageSize = DataSource.Count - startIndex; } return DataSource.GetRange(startIndex, PageSize); } else { DataTable dt = KingLib.DataHelper.ListToDataTable<T>(DataSource); DataView dv = dt.DefaultView; dv.RowFilter = FilterExpression; List<T> NewDataSource = KingLib.DataHelper.DataTableToList<T>(dv.ToTable()); count = NewDataSource.Count; int startIndex = CurrentPageIndex * PageSize; if (startIndex + PageSize > NewDataSource.Count) { PageSize = NewDataSource.Count - startIndex; } return NewDataSource.GetRange(startIndex, PageSize); } }
相关文章推荐
- List<T> 分页方式,泛型分页方式
- java list<泛型> 一行代码实现去重方式总结
- java中的泛型———List<>
- 绕过泛型,通过反射把 String 添加到 List<Integer> 中
- ajax遍历List<对象>的三种方式
- 交集、并集、余集——多种方法/List<Integer> 泛型
- C#之 List <>泛型集合
- resetTemplate的GET请求返回值为带泛型的类型list<>
- 泛型,动态创建List<T> (转摘)
- List<T>泛型集合 类型整体快速转换
- C#中泛型集合List<T>反序列化问题及解决方法
- C#基础精华03(常用类库StringBuilder,List<T>泛型集合,Dictionary<K , V> 键值对集合,装箱拆箱)
- 利用反射实现mysql数据库sql查询 返回List<E>泛型(持久化)对象
- Hibernate中用纯SQL查询,并通过hibernate分页返回List<对象>
- Class<T>泛型对象的获取及通过继承了HibernateDaoSupport的注入sessionFacoty的简单方式
- DataSet和List<T> 泛型之间互相转换
- NO.94 RestTemplate.getForObject将PO中List<T>的泛型变成LinkedHashMap问题的解决
- 泛型集合List<>
- 将泛型集合类(List<T>)转换成DataTable,返回的DataTable所有列的数据类型为string型,且列顺序与字符串提供的字段顺序一致
- C#中string[]数组和list<string>泛型的相互转换 【转】