Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是一个虚构的查询
"select * from tbl where name like '@foo%'" ... cmd.addparam(foo, bar) //not actual code
我得到 0 个结果。我尝试更改 where toname like @foo并写 bar+"%" 但是我怀疑这是不正确的(它应该转义 %?)并且我又得到了 0 行。
name like @foo
我如何使用参数?我的代码实际上使用 dapper.net 和 mysql 作为其数据库。
您需要按如下方式构建查询:
"select * from tbl where name like @foo"
然后
cmd.addParam("@foo", bar + "%")