基于 SubSonic 的应用程序可连接到多个数据库

发布于 2024-08-18 05:38:24 字数 367 浏览 3 评论 0原文

我目前开发了一个连接到 SQL Server 2005 数据库的应用程序,因此我的 DAL 对象是使用该数据库中的信息生成的。

还可以连接到 Oracle 和 MySQL 数据库,它们都具有相同的表结构(除了字段中的正常差异,例如 SQL Server 中的 varbinary(max) 和 Oracle 中的 BLOB 等)。为此,我已经为应用程序将运行的不同数据库定义了多个连接字符串和多个 SubSonic 提供程序。

我的问题是,如果我使用 SQL Server 数据库生成对象,生成的对象是否应该与其他数据库透明地工作,或者我是否需要为我使用的每个数据库引擎生成不同的 DAL?我是否应该注意执行这些操作时可能遇到的任何错误?

预先感谢您对这个问题的任何建议。

I currently developed an app that connects to SQL Server 2005 database, so my DAL objects where generated using information from that DB.

It will also be possible to connect to an Oracle and MySQL db, all with the same table structures (aside from the normal differences in fields, such as varbinary(max) in SQL Server and BLOB in Oracle, and so on). For this purpose, I already defined multiple connection strings and multiple SubSonic providers for the different DB's the app will run on.

My question is, if I generated my objects using a SQL Server database, should the generated objects work transparently with the other DB's or do I need to generate a different DAL for each database engine I use? Should I be aware of any possible bugs I may encounter while performing these operations?

Thanks in advance for any advice on this issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不再见 2024-08-25 05:38:24

顺便说一句,我正在使用 SubSonic 2.2...

从我迄今为止所进行的测试来看,我看不到一种简单的方法来实现我想要做的事情。

对我来说,理想的情况是使用 SQL Server 生成 SubSonic 对象,并且只需在运行时为其创建正确的 Provider 及其连接字符串即可动态切换到 MySQL。我的应用程序可以正确地从 SQL Server 连接到 MySQL 数据库,但有一点应用程序会失败,因为 SubSonic 内部生成

SELECT * FROM dbo.MyTable

MySQL 显然不支持的形式的查询。我还注意到查询用方括号 ([]) 括住表名,因此似乎有许多因素会限制在多个数据库引擎中使用一个提供程序。

我想我唯一的其他选择是使用多个生成的提供程序对其进行排序,尽管我必须承认,知道我将在项目中拥有基本相同的类的 N 个副本,这并不会让我感到舒服。

如果其他人有类似的经历,我真的很想听听他们的意见。一旦我整理好一切并为我的项目工作,我一定会发布我的结果。

3.0 中有这些改变吗?如果在这件事上生活更轻松的话,这绝对是我升级的一个值得的理由......

I'm using SubSonic 2.2 by the way....

From what I've been able to test so far, I can't see an easy way to achieve what I'm trying to do.

The ideal situation for me would have been to generate SubSonic objects using SQL Server for example, and just be able to switch dynamically to MySQL by just creating at runtime the correct Provider for it along with its connection string. I got to a point where my app would correctly connect from SQL Server to a MySQL DB, but there's a point where the app fails since SubSonic internally generates queries of the form

SELECT * FROM dbo.MyTable

which MySQL doesn't support obviously. I also noticed queries that enclosed table names with brackets ([]), so it seems that there are a number of factors that would limit the use of one Provider along multiple DB engines.

I guess my only other option is to sort it out with multiple generated providers, although I must admit it does not make me comfortable knowing that I'll have N copies of basically the same classes along my project.

I would really love to hear from anyone else if they've had similar experiences. I'll be sure to post my results once I get everything sorted out and working for my project.

Has any of this changed in 3.0? This would definitely be a worthy reason for me to upgrade if life is any easier on this matter...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文