且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Dapper查询中转义“ @”?

更新时间:2022-06-20 04:06:43

哦。我想到了。如果您的 @param 实际上没有绑定任何内容,则会将其原样传递给基础 SqlCommand ,直接将其传递给数据库。

Oh. I figured it out. If you have a @param that isn't actually bound to anything, it's passed as-is to the underlying SqlCommand, which passes it straight to the DB.

换句话说,您无需执行任何特殊操作即可使其工作。我的第一个示例应该运行良好。愚蠢的我。

In other words, you don't need to do anything special to get this to work. My first example should run fine. Silly me.