Oracle (ODP.net) 的 SubSonic3 T4 模板为 ActiveRecord 生成奇怪的查询(方括号问题)
目前,我正在尝试将 SubSonic3 ORM(ActiveRecords 模式)与 Oracle (ODP.NET) 数据提供程序和 T4 模板结合使用来访问 Oracle 10g(版本 10.2.0.3.0)DB。
在处理了一些小故障后,我获得了模板来为我构建各种代码,我设法将其全部编译并运行,但我遇到了它为我生成的查询的问题。
跟踪/单步执行代码,我查看了正在生成的 SQL 查询,发现了这一点:
SELECT [t0].[SOME_COLUMN], [t1].[ANOTHER_COLUMN]
FROM [USER].[SOME_TABLE] AS t0
CROSS JOIN [USER].[ANOTHER_TABLE] AS t1
WHERE ([t0].[ID] = [t1].[ID])
我的代码抛出异常,并显示 Oracle 消息“缺少表达式:ORA-00936”。因此,我尝试直接在命令行运行此查询,但它出现错误并显示相同的消息。
然后,我删除了所有方括号(对我来说看起来不正确)和两个“AS”引用(第二行和第三行),并且查询运行良好。
有人可以向我解释为什么 SubSonic 这样做吗?或者更好的是,如何解决这个问题?
谢谢!
编辑:我想我还应该问(因为我不是Oracle专家):方括号正常/合法吗?那么“AS”运算符呢?
Currently, I'm trying to use SubSonic3 ORM (ActiveRecords mode) with the Oracle (ODP.NET) data provider and the T4 template to access an Oracle 10g (ver. 10.2.0.3.0) DB.
After dealing with a few minor glitches getting the templates to build the various code for me, I managed to get it all to compile and run, but I'm running into a problem with the Query that it generates for me.
Tracing/stepping thru the code, I took a look at what SQL query was being generated and found this:
SELECT [t0].[SOME_COLUMN], [t1].[ANOTHER_COLUMN]
FROM [USER].[SOME_TABLE] AS t0
CROSS JOIN [USER].[ANOTHER_TABLE] AS t1
WHERE ([t0].[ID] = [t1].[ID])
And my code was throwing an exception with an Oracle message of "Missing Expression: ORA-00936". So I tried running this query directly at the command-line and it error-ed out with the same message.
I then removed all the square brackets (which didn't look right to me) and both "AS" references (2nd and 3rd line) and the query ran fine.
Can someone explain to me why SubSonic is doing this? Or even better, how to fix this?
Thanks!
EDIT: I guess I should also ask (since I'm not an Oracle expert): Are the square-brackets normal/legal? What about the "AS" operator?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番挖掘,我发现对于 Oracle(可能还有 DB2)支持,SubSonic 上有一个来自主干的分支,它对这两个数据库有更好的支持。请点击此链接: https://github.com/rally25rs/SubSonic-3.0
此源代码出现成为真正的交易。
After doing some digging, I found that for Oracle (and possibly DB2) support, there is a fork from the trunk on SubSonic which has better support for these 2 databases. Follow this link: https://github.com/rally25rs/SubSonic-3.0
This source code appears to be the real deal.