【问题标题】:How to escape "?" in Expression.Sql in NHibernate (C#)如何逃脱“?”在 NHibernate 中的 Expression.Sql (C#)
【发布时间】:2019-03-06 18:48:02
【问题描述】:

当我尝试在 Expression.Sql 中使用 Postgresql '?' operator 时 它认为我正在尝试添加一个新参数,但失败了。 示例:

Expression.Sql("(this_.data -> 'glossary' ->> 'GlossDiv')::jsonb ? ?", "testValue", NHibernateUtil.String);

[ADOExceptionReporter]:索引超出范围。必须是非负数且小于集合的大小。

如何逃脱?

【问题讨论】:

标签: nhibernate


【解决方案1】:

您能否尝试使用 SqlString 作为参数进行重载,它可能会对您有所帮助:

Expression.Sql(new SqlString(new object[]{"(this_.data -> 'glossary' ->> 'GlossDiv')::jsonb ? ", Parameter.Placeholder}), "testValue", NHibernateUtil.String);

【讨论】:

    猜你喜欢
    • 2017-10-31
    • 2016-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多