我需要自定义Interceptor
来自定义sql查询。
public class SqlStatementInterceptor : EmptyInterceptor
{
public override SqlString OnPrepareStatement(SqlString sql)
{
if (sql.ToString().Contains("INSERT INTO ATTACHMENT"))
{
//do something
}
return sql;
}
}
非编辑查询看起来像
INSERT INTO ATTACHMENT (TITLE, FILENAME, NAME,
PARENT_ID, TYPE_ID, ACCESS_TYPE, ARCHIVE_ID, ID, DOC_ID)
VALUES (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8)
returning ID into :nhIdOutParam;
:p0 = NULL [Type: AnsiString (0)],
:p1 = 'unitAttachmentTest_8185_a001.txt' [Type: AnsiString (35)],
//another params
:p8 = 8185 [Type: Int32 (0)]
提交实体ID通过returning ID into :nhIdOutParam
更新后的现在我需要自定义查询以更新另一个字段(它生成db-first)
所以我想在Interceptor
中使用像
var sb = new SqlStringBuilder(sql);
sb.Add("returning TYPE_ID into :nhIdOutParam2");
sql = sb.ToSqlString();
但收到错误ORA-01008 not all variables bound
如何将:nhIdOutParam2
参数绑定到属性?