本文介绍了相同代码库的不同SQL管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要连接SQL服务器的项目。问题是库需要在两个不同的位置运行,并且需要访问两个不同的数据管理器。两个数据管理器中的方法名称是相同的,但我不知道如何实现它。



可能有人给我一个例子。



详细解释:



我有一个项目:MyProject



有两个不同的数据管理器类(在不同的dll中)都命名为DataManager(不确定这是否有所不同)



1. DataManager(使用名为的方法) getnames(),getdata()....) - 有代码访问伦敦的SQL服务器。



2. DataManager(使用名为getnames()的方法, getdata()....) - 有代码访问巴黎的SQL服务器。



我不想生成2个独立的MyProject dll(一个与巴黎引用了DataManager,引用了伦敦DataManager。我无法更改任何DataManager的代码,但我可以自由修改MyProject。



PS:访问数据的方法名称在两个类中完全相同。

I have a project which requires connection to SQL servers. The problem is that the library needs to run at 2 different locations and needs to access two different data managers. The method names inside both data managers are the same but I have no idea how to implement this.

Could some one give me an example.

Detailed explanation :

I have a project : MyProject

There are two different data manager classes(in separate dlls) both named "DataManager"(not sure if this makes a difference)

1. DataManager(with methods named getnames(), getdata() ....) -- has code to access SQL servers in London.

2. DataManager(with methods named getnames(), getdata() ....) -- has code to access SQL servers in Paris.

I do not want to produce 2 separate dlls of MyProject (one with Paris DataManager referenced and one with London DataManager referenced). I cannot change the code of either DataManager but I am free to modify MyProject.

PS : The method names to access the data are exactly the same in both classes.

推荐答案


var lon = London.DataManager.getnames();
var par = Paris.DataManager.getnames();



Or

London.DataManager lon = new London.DataManager();
Paris.DateManager par = new Paris.DataManager();
var lonnames = lon.getnames();
var parnames = par.getnames();


<connectionstrings>
   <add name="London" connectionstring="(Paste your connection Properties)Data Source=localhost;Initial Catalog=YourDataBaseName;Integrated Security=True;" providername="System.Data.SqlClient" />
 </connectionstrings>





根据您的问题,下面提到另一个。



another is mention below as per your problem.

<connectionstrings>
   <add name="Paris" connectionstring="(Paste your connection Properties)Data Source=localhost;Initial Catalog=YourDataBaseName;Integrated Security=True;" providername="System.Data.SqlClient" />
 </connectionstrings>





我希望你的问题已经解决,点击回复了解更多信息。

Happy Coding☺



I hope your problem has been solved,hit to reply for more information.
Happy Coding ☺


这篇关于相同代码库的不同SQL管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 03:05