使用小巧精致与Oracle [英] Using Dapper with Oracle

查看:177
本文介绍了使用小巧精致与Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用Oracle作为我们的供应商数据库,并调查了一些替代我们的数据访问层(难以维护,难以合并XSD的),用精致小巧的底层一个理智的库基于模式。然而,在Oracle使用时,我们打了一些问题。

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.


  • 命名参数:这些似乎被忽略,每当他们在查询甲骨文似乎解释他们在任何顺序使用它望梅止渴。该SqlMapper返回正确命名的参数,他们只是没有在甲骨文正确的解释

  • 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

的@命名约定变量与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?

推荐答案

IMO,正确的做法在这里的以(按接受的答案)使用数据库特定参数的前缀(所以 @ 为SQL服务器,用于Oracle) - 但而:不使用前缀的所有的。所以,最后是这样的:

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)

在特定的,一个静态属性将是不好的,因为它会限制你每的AppDomain 一个供应商。

In particular, a static property would be bad as it would limit you to one vendor per AppDomain.

小巧玲珑已经更新了这种变化。它也可以动态地检测 BindByName ,并将其设置相应的(所有,而无需参考的OracleCommand )。

Dapper has been updated with this change. It also now dynamically detects BindByName and sets it accordingly (all without needing a reference to OracleCommand).

这篇关于使用小巧精致与Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆