zoukankan      html  css  js  c++  java
  • Last time, I wrote a pager, but now it seems this no longer has use, so I want to paste it here.

        public class Pager<T> where T : new()
        {
            private IEnumerable<T> _all;
            private IEnumerable<T> _current;
            public Pager()
                : this(0, 1000)
            {
    
            }
            public Pager(int pageIndex, int pageSize)
                : this(null, pageIndex, pageSize)
            {
            }
            public Pager(IEnumerable<T> items, int pageIndex = 0, int pageSize = 10)
            {
                PageIndex = pageIndex;
                PageSize = pageSize;
                if (items != null)
                {
                    _all = items;
                    var count = _all.Count();
                    PageCount = count % pageSize > 0 ? (count / pageSize + 1) : count / pageSize;
                }
            }
    
    
            public int PageIndex { get; set; }
            public int PageSize { get; private set; }
            public int PageCount
            {
                get;
                set;
            }
    
            public IEnumerable<T> Current
            {
                get
                {
                    if (_all != null) _current = _all.Skip(PageIndex * PageSize).Take(PageSize);
                    return _current;
                }
                set { _current = value; }
            }
    
        }

    this pager supports dual methods, memory pagination or direct usage.

  • 相关阅读:
    分数的表示和运算
    用户管理
    DML,DDL
    索引
    sql语句执行顺序
    伪劣
    序列
    视图
    完整性约束
    ASP.NET MVC学习笔记(二)登陆验证
  • 原文地址:https://www.cnblogs.com/hualiu0/p/6144457.html
Copyright © 2011-2022 走看看