亚音速:动态连接 [英] Subsonic: dynamic connections

查看:187
本文介绍了亚音速:动态连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个古老的烂摊子我试图铲进用亚音速层。麻烦的是,我有这样的情况:

当哈尔登录时,他的登录使用数据库x对于查找数据,数据库Y表示他的帐户和数据库Z表示他交往。

当巴里登录时,他的登录使用数据库x对于lookupdata,数据库Q代表他的帐户和数据库R代表他交往。

,X,Y,Z,Q和R是相同的服务器上的所有。 Y具有一个张玉峰架构Q,并和Z具有相同的架构R.不要让我开始对如何愚蠢的一个设置,这是:)

我必须让我的.NET WinForms应用程序(使用亚音速)指向正确的数据库。

据我所知道的,我必须让我的手脏改变亚音速源(并保持与每一个亚音速释放这些变化),因此它可以接受参数,而不是使用app.config中。任何人都可以看到来替代?

解决方案

谢谢你们。我已经有多个供应商制定了,但不知道如何设置在运行时(我已经搜查这个论坛。必须使用了错误的关键字)。

SharedDBConnectionScope似乎完美的飞行,但似乎没有专门用来设置提供商为整个用户会话。<​​/ P>

所以,我没有更多的基础上搜索你的答案以上,并提出了以下解决方案:

1)添加三个供应商进行查找,客户和联系人,并生成DAL。

2),将其添加到DAL:

 公共静态无效SetProvider(字符串strProvider,串strConnectionString)
{
    DataService.GetInstance(strProvider).DefaultConnectionString =
                                                     strConnectionString;
}
 

3)调用它的登录,一旦我的应用程序已制定了哪些数据库的用户使用,如:

  MyDAL.SSProvider.SetProvider(查找,
            服务器= 10.123.456.78;端口= 3306;的uid =什么; PWD =等等;数据库= X)

MyDAL.SSProvider.SetProvider(帐户,
      服务器= 10.123.456.78;端口= 3306;的uid =什么; PWD =等等;数据库= Y)

MyDAL.SSProvider.SetProvider(联系人,
               服务器= 10.123.456.78;端口= 3306;的uid =什么; PWD =等等;数据库= Z)
 

和关闭它去。

I have an ancient mess I'm trying to shovel into tiers using subsonic. Trouble is, I have this scenario:

When Hal logs in, his login uses database X for lookup data, database Y for his accounts and database Z for his contacts.

When Barry logs in, his login uses database X for lookupdata, database Q for his accounts and database R for his contacts.

X,Y,Z,Q and R are all on the same server. Y has an indentical schema to Q, and and Z has an identical schema to R. Don't get me started on how stupid a setup this is :)

I have to make my .NET Winforms App (using subsonic) point to the correct databases.

As far as I can tell, I'll have to get my hands dirty changing the SubSonic source (and maintain those changes with every subsonic release), so it can accept parameters rather than use app.config. Can anyone see an alternative to this?

解决方案

Thanks guys. I already had the multiple providers worked out, but didn't know how to set them at runtime (and I already searched this forum. Must have used the wrong keywords).

SharedDBConnectionScope seems perfect for on the fly, but didn't seem designed to set the provider for the whole user session.

So I did more searching based on your answers above, and came up with the following solution:

1) Add three providers for lookups, accounts and contacts, and generate the DAL.

2) add this to the DAL:

public static void SetProvider(string strProvider,string strConnectionString)
{
    DataService.GetInstance(strProvider).DefaultConnectionString = 
                                                     strConnectionString;
}

3) call it on login, once my app has worked out which databases the user uses, eg

MyDAL.SSProvider.SetProvider("Lookups", 
            "server=10.123.456.78;port=3306;uid=whatever;pwd=blah;database=X")

MyDAL.SSProvider.SetProvider("Accounts", 
      "server=10.123.456.78;port=3306;uid=whatever;pwd=blah;database=Y")

MyDAL.SSProvider.SetProvider("Contacts",    
               "server=10.123.456.78;port=3306;uid=whatever;pwd=blah;database=Z")

And off it goes.

这篇关于亚音速:动态连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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