在asp.net中使用不同的数据源创建n层体系结构 [英] create n tier architecture in asp.net with different datasource

查看:92
本文介绍了在asp.net中使用不同的数据源创建n层体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想在asp.net中使用两个不同的数据源创建N层体系结构.

我的项目将使用asp.net 3.5框架运行,后端是Oracle和Sql Server2005.

每当将项目安装在服务器中时,它就会决定它将运行Oracle还是Sql Server2005.将从数据库中读取这些设置(数据库类型[< add key ="DBType" value ="Oracle"/>]). .config文件.

我不想使用NHibernate.


请帮帮我.


在此先感谢.
Gautam

Hi all,

I want to create N-tier architecture with two different datasources in asp.net.

My project would be running with asp.net 3.5 framework and backend are Oracle and Sql Server 2005.

Whenever project would be install in server then it will decide that it will running Oracle or Sql Server 2005. These setting(Database type [<add key="DBType" value="Oracle" />]) would be read from web.config file.

I don''t want to use NHibernate.


Please help me.


Thanks in Advance.
Gautam

推荐答案

NHibernate与什么有关系?因为这是两个数据库,所以您要做的就是在每个数据库中写入存储的proc,这些proc具有相同的参数并返回相同的值,并让用户在web.config中指定他们喜欢的任何DB类型的连接字符串. .然后,您可以使用通用类,或者,如果愿意,可以编写两个数据层,以便可以使用SQL Server和Oracle特定的类,但是我看不出这样做会有什么好处,特别是.在这种情况下,您将需要某种标志来告诉系统使用哪个标志.
What does NHibernate have to do with anything ? As these are two databases, all you need to do, is write stored procs in each database that take the same paremeters and return the same values, and let the user specify a connection string in the web.config, to whatever DB type they prefer. You can then use the generic classes, or if you prefer, you can write two data layers so you can use SQL Server and Oracle specific classes, but I don''t see what benefit that would be, especially. In that case, you''d need some sort of flag to tell the system which one to use.


您将需要在DAL层中进行处理.但是,在同一个应用程序中同时使用Oracle和SQL Server绝非易事.一起使用大型对象时,处理大型对象和日期格式应特别不同.
You will need to handle this in the DAL layer. However, using Oracle and SQL Server together within the same app is never an easy thing to do. Be especially vary of handling large objects and also date formatting when using them together.


您可以使用Microsoft提供的数据访问应用程序块.我已经将它用于在Oracle或SQL Server上运行的一个应用程序.要了解有关此访问的更多信息

http://msdn.microsoft.com/en-us/magazine/cc163766.aspx [ ^ ]
You can use Data Access Application Block provided by Microsoft. I have used this for one application which runs on Oracle or SQL server. To know more about this visit

http://msdn.microsoft.com/en-us/magazine/cc163766.aspx[^]


这篇关于在asp.net中使用不同的数据源创建n层体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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