dapper 参数不定时用这种方法动态参数

       string where = null;
            var p = new DynamicParameters();
            if (classId != null)
            {
                where = " and classId=:classId ";
                p.Add("classId", classId);
            }
            if (key != null)
            {
                where = " and (name like :key or description like :key) ";
                key = string.Format("%{0}%", key);
                p.Add("key", key);
            }

 

posted @ 2017-08-17 08:26  dong00a  阅读(570)  评论(0编辑  收藏  举报