コード例 #1
0
        public PageBox Query(int pageIndex = 1, int pageSize = 3, string Name = "", int TId = 0, int SId = 0, int isUse = -1)
        {
            var list = bll.Query();

            if (!string.IsNullOrWhiteSpace(Name))
            {
                list = list.Where(m => m.Name.Contains(Name)).ToList();
            }
            if (TId != 0)
            {
                list = list.Where(m => m.TId.Equals(TId)).ToList();
            }
            if (SId != 0)
            {
                list = list.Where(m => m.SId.Equals(SId)).ToList();
            }
            if (isUse != -1)
            {
                list = list.Where(m => m.IsUse.Equals(isUse)).ToList();
            }
            PageBox page = new PageBox
            {
                PageIndex = pageIndex,
                PageCount = list.Count / pageSize + (list.Count % pageSize > 0 ? 1 : 0),
                Data      = list.Skip((pageIndex - 1) * pageSize).Take(pageSize)
            };

            return(page);
        }