We use Oracle as our database provider and have looked into replacing some of our data access layer (hard to maintain, harder to merge XSD's) with a saner repository based pattern using Dapper at the bottom layer. However, we have hit a number of issues when using it with oracle.
Named Parameters: these seem to be ignored, whenever they are used in a query Oracle seems to interpret them in any order it fancies. The SqlMapper returns correctly named parameters, they just aren't interpreted correctly in Oracle
The "@" naming convention for variables is incompatible with oracle named parameters. It expects to see ":" in front of any parameters
Has anybody previously encountered this and have any workarounds?
Using oracle database with . net core can be a hassle. By connecting oracle with dapper as a micro orm, life can get easy. Here we will discuss some effective way to establish a connection with oracle database using .
Work with any database - SQL Server, Oracle, SQLite, MySQL, PostgreSQL etc. For an existing database, using Dapper is an optimal choice.
Dapper is a popular open-source, micro-ORM solution that is compatible with the . NET application framework. It lets you work with strongly typed data that constantly changes without spending hours writing code. It is especially useful when dealing with unnormalized databases.
Dapper is an example of Micro ORM, in fact, it is called the King of Micro ORM because of its speed and ease of work. First, it creates an IDbConnection object and allows us to write queries to perform CRUD operations on the database.
IMO, the correct approach here is not to (as per the accepted answer) use the database specific parameter prefix (so @
for sql-server, :
for oracle) - but rather: use no prefix at all. So ultimately this is:
il.Emit(OpCodes.Ldstr, prop.Name);
(etc)
In particular, a static
property would be bad as it would limit you to one vendor per AppDomain
.
Dapper has been updated with this change. It also now dynamically detects BindByName
and sets it accordingly (all without needing a reference to OracleCommand
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With