コード例 #1
0
        public PageModel <GoodsBrand> SearchListByPage(GoodsBrandParam param, PageInfo pageInfo)
        {
            string sqlWhere = " where 1=1 ";
            var    sqlParam = new List <DbParameter>();

            if (param.IsDel != -1)
            {
                sqlWhere += " and IsDel = @IsDel ";
                sqlParam.Add(new MySqlParameter("@IsDel", param.IsDel));
            }

            if (!string.IsNullOrEmpty(param.GoodsBrandName))
            {
                sqlWhere += " and (ChsBrandName like @GoodsBrandName or EnBrandName like @GoodsBrandName) ";
                sqlParam.Add(new MySqlParameter("@GoodsBrandName", "%" + param.GoodsBrandName + "%"));
            }

            string sql = @"select * from GoodsBrand " + sqlWhere + " order by id desc ";

            string sqlCount = "select count(*) from GoodsBrand " + sqlWhere;

            var list  = _context.Database.SqlQuery <GoodsBrand>(sql.ToPaginationSql(pageInfo), sqlParam.ToArray());
            var count = _context.Database.ExcuteSclare(sqlCount, sqlParam.ToArray());

            return(new PageModel <GoodsBrand>(list, pageInfo.PageIndex, pageInfo.PageSize, Convert.ToInt32(count)));
        }
コード例 #2
0
        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="param"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public IActionResult SearchListByPage(GoodsBrandParam param, PageInfo pageInfo)
        {
            var result = _goodsBrandRepository.SearchListByPage(param, pageInfo);

            return(Json(result));
        }