OrmLite select 查询中的大括号抛出错误

Curly brackets in OrmLite select query throws error

似乎 OrmLite 普通 select 扩展方法 (Select<T>) 尝试格式化查询字符串(如 SelectFmt<T>),因此如果查询字符串包含大括号,它假定缺少参数。

示例查询:

db.Select<Company>("Website='http://www.test.com/?session={123}'");

抛出错误:

Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

理想情况下,Select<T> 应该只逐字执行查询,不带任何字符串格式。

这是 OrmLite 中的错误还是其他原因?!

更新: 问题似乎是 here in OrmLiteDialectProviderBase class。它应该检查参数长度等。

您可以使用 SqlList<T> API 的 executing Custom SQL 来跳过 OrmLite 的预处理,但您需要提供完整的 SQL 声明,例如:

var results = db.SqlList<Company>(
  "SELECT * FROM Company WHERE Website='http://www.test.com/?session={123}'");