Esempio n. 1
0
        /// <summary>
        /// 根据前台传递的参数,对"字典"数据进行分页,搜索
        /// </summary>
        /// <param name="pageNumber">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="number">返回的total总数</param>
        /// <param name="sort">排序字段</param>
        /// <param name="sortOrder">排序标识asc或desc</param>
        /// <param name="search">搜索的字符串</param>
        /// <returns></returns>
        public List <T_Sys_Dict> GetDictPages(int pageNumber, int pageSize, out long number, string sort = null, string sortOrder = null, string search = null)
        {
            //List < T_Sys_Dict > dicts =dao.GetPageList<T_Sys_Dict>(pageNumber,pageSize,out number).ToList();
            //创建谓词
            IFieldPredicate predicate = null;

            if (!string.IsNullOrEmpty(search))
            {
                predicate = Predicates.Field <T_Sys_Dict>(f => f.DICT_NAME, Operator.Like, "%" + search + "%");
            }
            IList <ISort> sorts = new List <ISort>();

            //创建排序
            if (sort == null)
            {
                sorts.Add(new Sort {
                    PropertyName = "DICT_CODE", Ascending = sortOrder == "asc" ? true : false
                });
            }
            else
            {
                sorts.Add(new Sort {
                    PropertyName = sort, Ascending = sortOrder == "asc"?true:false
                });
            }
            List <T_Sys_Dict> dicts = dao.GetPageList <T_Sys_Dict>(pageNumber, pageSize, out number, predicate, sorts).ToList();

            return(dicts);
        }