我正在使用Dapper通过OleDb连接到ODBC驱动器。
以下帖子: Dapper WHERE IN statement with ODBC 可以将列表作为命名参数传递,这很棒:)
但是我仍然有问题传递一组参数,包括列表。
让我举个例子:
这有效:
sql = @"select 1 from dual where 1 = ?id1? and 2 = ?id2?"
conn.Query<int>(sql, new { id1 = 1, id2 = 2 });
这有效:
sql = @"select 1 from dual where 1 in ?ids?";
conn.Query<int>(sql, new {ids = new[]{1, 2}});
但是这会抛出一个AccessViolationException:
sql = @"select 1 from dual where 1 = ?id1? and 2 in ?ids?";
conn.Query<int>(sql, new { id1 = 1, ids = new[] { 1, 2 } });
异常的描述是:尝试读取或写入受保护的内存。这通常表明其他内存已损坏。 的
这是Dapper的预期行为吗?如果是,为什么以及如何绕过它?