Why does Dapper throw an OracleException when I run a query or command with parameters?

I appreciate dapper, but I am already facing some problems.

I'm trying to do it

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

It throws ORA-00936: missing OracleException expression on line 393 in SqlMapper.cs

 using (var reader = cmd.ExecuteReader()) 

When I remove the parameter, I get the whole table in the result variable.

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

+8
oracle exception oracle11g orm dapper
source share
2 answers

I think oracle has a different scheme for the named parameter, you tried :a instead of @a ?

+18
source share

Yes, it works with ":" if we try to insert records into the oracle database table.

Just try it like this:

 var count = connection.Execute(@"INSERT INTO COMPANY_USER(UserId , UserName) values (:UserId, :UserName)", new[] { new { UserId = 1, UserName = "Sam" }, new { UserId = 2, UserName = "Don" }, new { UserId = 3, UserName = "Mike" } }); 
+2
source share

All Articles