本来语句是这样,但是死活没有值
if (!string.IsNullOrEmpty(input.参数))
{
sqlWhere += $" and a.tym like ‘%@参数%’";
parameters.Add(new MySqlParameter("@参数", input.参数));
}
然后改为
if (!string.IsNullOrEmpty(input.参数))
{
sqlWhere += $" and a.tym like @参数";
parameters.Add(new MySqlParameter("@参数", “%”+input.参数+"%"));
}
MySqlParameter这个对象,第一个参数是参数名,第二个是参数值,所以我们直接给值来加%就好了
最近发现经常忘了很多代码技巧,以后开始记录自己的代码小技巧
如果以上文章帮助到了您,不论在任何时候,请点个关注,谢谢