Ejemplo n.º 1
0
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public async Task <JqGridModel <RolesModel> > GetList(RolesParam param)
        {
            string sql     = "select Roles.* {0} from Roles {1} where 1=1 {2} {3}";
            string orderBy = " ORDER BY Id ";

            string where = string.Empty;
            string join   = "";
            string select = "";

            //条件
            if (!string.IsNullOrEmpty(param.SearchKey))
            {
                where += string.Format(" and( RoleName like '%{0}%')", param.SearchKey);
            }
            //排序
            if (!string.IsNullOrEmpty(param.sidx) && !string.IsNullOrEmpty(param.sord))
            {
                orderBy = string.Format(" order by {0} {1} ", param.sidx, param.sord);
            }

            sql = string.Format(sql, select, join, where, orderBy);

            var list = await rolesRepository.FindListPager <RolesModel>(sql, param);

            return(list);
        }