为什么Dapper在运行带有参数的查询或命令时抛出OracleException?(Why does Dapper throw an OracleException when i run a query or command with parameters?)

我是评估小巧,但我已经遇到了一些问题。

我正在努力做到这一点

using (IDbConnection connection = GetConnection()) { connection.Open(); var result = connection.Query( "select * from myTable where ID_PK = @a;", new { a = 1 }); }

它在SqlMapper.cs的第393行抛出ORA-00936:缺少表达式OracleException

using (var reader = cmd.ExecuteReader())

当我删除参数时,我将整个表格放入结果变量中。

查询在sqldeveloper中没有问题。 我正在使用Oracle.DataAccess程序集2.112.2.0

I am evaluation dapper but i already running into some problems.

I am trying to do this

using (IDbConnection connection = GetConnection()) { connection.Open(); var result = connection.Query( "select * from myTable where ID_PK = @a;", new { a = 1 }); }

It throws an ORA-00936: missing expression OracleException at line 393 in the SqlMapper.cs

using (var reader = cmd.ExecuteReader())

When i remove the parameter i get the whole table into the result variable.

The query works without problems in sqldeveloper. I am using the Oracle.DataAccess Assembly 2.112.2.0

最满意答案

我认为甲骨文有一个命名参数不同的架构,你尝试:a而不是@a ?

I think oracle has a different schema for named parameter, did you try :a instead of @a?

为什么Dapper在运行带有参数的查询或命令时抛出OracleException?(Why does Dapper throw an OracleException when i run a query or command with parameters?)

我是评估小巧,但我已经遇到了一些问题。

我正在努力做到这一点

using (IDbConnection connection = GetConnection()) { connection.Open(); var result = connection.Query( "select * from myTable where ID_PK = @a;", new { a = 1 }); }

它在SqlMapper.cs的第393行抛出ORA-00936:缺少表达式OracleException

using (var reader = cmd.ExecuteReader())

当我删除参数时,我将整个表格放入结果变量中。

查询在sqldeveloper中没有问题。 我正在使用Oracle.DataAccess程序集2.112.2.0

I am evaluation dapper but i already running into some problems.

I am trying to do this

using (IDbConnection connection = GetConnection()) { connection.Open(); var result = connection.Query( "select * from myTable where ID_PK = @a;", new { a = 1 }); }

It throws an ORA-00936: missing expression OracleException at line 393 in the SqlMapper.cs

using (var reader = cmd.ExecuteReader())

When i remove the parameter i get the whole table into the result variable.

The query works without problems in sqldeveloper. I am using the Oracle.DataAccess Assembly 2.112.2.0

最满意答案

我认为甲骨文有一个命名参数不同的架构,你尝试:a而不是@a ?

I think oracle has a different schema for named parameter, did you try :a instead of @a?