支持SqlServer和Oracle的数据提供程序

时间:2021-01-31 07:46:54

I'm working on an ASP.Net application that uses .NET 3.5 framework. I need to implement a provider that works well with both Oracle and Sql Server, and also maybe MySql, because we are going to sell the product to clients who may have any one of these databases and the application should be able to communicate with any of these data sources. What is the best approach to implement this? Also, can anyone provide me links to some sample examples? Thank you.

我正在开发一个使用.NET 3.5框架的ASP.Net应用程序。我需要实现一个适用于Oracle和Sql Server以及MySql的提供程序,因为我们要将产品销售给可能拥有这些数据库中的任何一个的客户端,并且应用程序应该能够与任何这些数据来源。实现这个的最佳方法是什么?此外,任何人都可以提供一些示例示例的链接吗?谢谢。

3 个解决方案

#1


Why do you want to write one dataprovider for all databases? just write configurator that helps clients to configure system for specified database by selecting database type and other database properties, and change app.config file by writing specified dataprovider in your configurator

为什么要为所有数据库编写一个数据提供者?只需编写配置程序,通过选择数据库类型和其他数据库属性帮助客户端为指定数据库配置系统,并通过在配置程序中编写指定的dataprovider来更改app.config文件

EDIT

Here are the ways to use DbProviderFactory, you can find more samples in web, just use this classes instead of specified ones Obtaining the DbProviderFactory, Create Provider-Independent Data Access Code with ADO.NET 2.0

以下是使用DbProviderFactory的方法,您可以在Web中找到更多示例,只需使用此类而不是指定的类获取DbProviderFactory,使用ADO.NET 2.0创建独立于提供程序的数据访问代码

#2


You could use the Enterprise Library - which conforms to the provider model. It already has hooks for Oracle and SQL Server and you can extend this into any other database quite easily. We did it at work for DB2.

您可以使用企业库 - 它符合提供者模型。它已经有了Oracle和SQL Server的钩子,你可以很容易地将它扩展到任何其他数据库。我们在为DB2工作时做到了。

See more here: http://www.codeplex.com/entlib

在此处查看更多信息:http://www.codeplex.com/entlib

#3


Use the .net provider model to create seperate providers for each data source and implement an Inversion of Control Container like Castle .net or Spring to determine which provider to use.

使用.net提供程序模型为每个数据源创建单独的提供程序,并实现一个Inversion of Control Container,如Castle .net或Spring,以确定要使用的提供程序。

Or use the EntityFramework, the link below includes a whole test project with two different data sources.

或者使用EntityFramework,下面的链接包含一个包含两个不同数据源的整个测试项目。

http://msdn.microsoft.com/en-us/magazine/dd263098.aspx

#1


Why do you want to write one dataprovider for all databases? just write configurator that helps clients to configure system for specified database by selecting database type and other database properties, and change app.config file by writing specified dataprovider in your configurator

为什么要为所有数据库编写一个数据提供者?只需编写配置程序,通过选择数据库类型和其他数据库属性帮助客户端为指定数据库配置系统,并通过在配置程序中编写指定的dataprovider来更改app.config文件

EDIT

Here are the ways to use DbProviderFactory, you can find more samples in web, just use this classes instead of specified ones Obtaining the DbProviderFactory, Create Provider-Independent Data Access Code with ADO.NET 2.0

以下是使用DbProviderFactory的方法,您可以在Web中找到更多示例,只需使用此类而不是指定的类获取DbProviderFactory,使用ADO.NET 2.0创建独立于提供程序的数据访问代码

#2


You could use the Enterprise Library - which conforms to the provider model. It already has hooks for Oracle and SQL Server and you can extend this into any other database quite easily. We did it at work for DB2.

您可以使用企业库 - 它符合提供者模型。它已经有了Oracle和SQL Server的钩子,你可以很容易地将它扩展到任何其他数据库。我们在为DB2工作时做到了。

See more here: http://www.codeplex.com/entlib

在此处查看更多信息:http://www.codeplex.com/entlib

#3


Use the .net provider model to create seperate providers for each data source and implement an Inversion of Control Container like Castle .net or Spring to determine which provider to use.

使用.net提供程序模型为每个数据源创建单独的提供程序,并实现一个Inversion of Control Container,如Castle .net或Spring,以确定要使用的提供程序。

Or use the EntityFramework, the link below includes a whole test project with two different data sources.

或者使用EntityFramework,下面的链接包含一个包含两个不同数据源的整个测试项目。

http://msdn.microsoft.com/en-us/magazine/dd263098.aspx