首页 > 移动平台 > 详细

Dapper+Mysql 使用LIKE模糊查询写法采坑

时间:2019-07-01 18:13:46      阅读:232      评论:0      收藏:0      [点我收藏+]
LIKE ‘%@Title%‘ 会解析成‘%‘@Title‘%‘ 这里用拼接也是不行的‘%‘+@Title+‘%‘ 只能用MySQL函数方法拼接
public dynamic GetListByFilter(ArticleModel filter, PageInfo pageInfo)
        {
            string _where = " where 1=1";
            if (!string.IsNullOrEmpty(filter.Title))
            {
                //LIKE ‘%@Title%‘ 会解析成‘%‘@Title‘%‘ 这里用拼接也是不行的‘%‘+@Title+‘%‘ 只能用MySQL函数方法拼接
                _where += " and Title LIKE CONCAT(‘%‘,@Title,‘%‘)";
            }
            if (filter.Status != null)
            {
                _where += " and Status=@Status";
            }
            return GetListByFilter(filter, pageInfo, _where);
        }

  

Dapper+Mysql 使用LIKE模糊查询写法采坑

原文:https://www.cnblogs.com/baocaige/p/11115446.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!