Curly brackets in OrmLite select query throws error
It seems like OrmLite plain select extension method ( Select<T>
) tries to format the query string (like SelectFmt<T>
), and so it throws an error if the query string contains curly brackets, which it assumes are missing arguments.
Example query:
db.Select<Company>("Website='http://www.test.com/?session={123}'");
Error thrown:
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Ideally, Select<T>
should just execute the query verbatim, without any string formatting.
Is it a bug in OrmLite, or something else?!
Update: Seems like the issue is here in OrmLiteDialectProviderBase class. It should have a check for params length etc.
您可以使用SqlList<T>
API来执行自定义SQL,以避免OrmLite进行预处理,但您需要提供完整的SQL语句,例如:
var results = db.SqlList<Company>(
"SELECT * FROM Company WHERE Website='http://www.test.com/?session={123}'");
链接地址: http://www.djcxy.com/p/65976.html
上一篇: [参考]或[忽略]?