SubSonic ASP.NET Providers Project (and Announcement) – Zack Owens
http://weblogs.asp.net/zowens/archive/2007/10/14/subsonic-asp-net-providers-project-and-announcement.aspx



Config for Subsonic in Winform | HieuUK
http://www.hieu.co.uk/blog/index.php/2009/04/11/config-for-subsonic-in-winform/



转:有关SubSonic的新消息 – Jolly-Zhang – 博客园
http://www.cnblogs.com/wliang22/archive/2008/09/04/1283759.html



Subsonic学习 – EricGu’s Record-Space – 博客园
http://www.cnblogs.com/EricGu/archive/2008/03/31/1131467.html



Subsonic设置 第2页|IT168 技术开发
http://tech.it168.com/d/2008-04-27/200804270932053_1.shtml



Subsonic 配置、安装、使用(1)_派行天下的空间
http://hi.baidu.com/ansonlau/blog/item/16dfdf5063f1d92d42a75bc7.html



Subsonic 配置、安装、使用(2)_㊣网络淘金_____________________
http://hi.baidu.com/feik/blog/item/f9964336b7d4e0d8a2cc2b44.html



SubSonic – Specifying DataProvider in a Select() function – Stack Overflow
http://stackoverflow.com/questions/747097/subsonic-specifying-dataprovider-in-a-select-function



Getting Started with SubSonic – Part 4, Configuration
http://geekswithblogs.net/scottkuhl/archive/2006/11/17/97470.aspx



Subsonic: dynamic connections – Stack Overflow
http://stackoverflow.com/questions/968391/subsonic-dynamic-connections
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.


Separate Read/Write Connection for SubSonic – Stack Overflow
http://stackoverflow.com/questions/828736/seperate-read-write-connection-for-subsonic/828825#828825



Digvijay’s Webb | SubSonic Trick : Specify connection string at runtime!
http://www.digvijay.eu/post/2008/10/30/SubSonic-Trick-Specify-connection-string-at-runtime!.aspx#comment
private static bool _bIsInitialized = false; private void InitSubsonic() { if (_bIsInitialized) return; DataService.Providers = new DataProviderCollection(); // here you can get settings from anywhere and make up a connection string :) CustomDataProvider provider = new CustomDataProvider(“Data Source=(local); Database=”WebShop”)); DataService.Providers.Add(provider); DataService.Provider = provider; _bIsInitialized = true; } // Here it is MySql that i needed but you // may have any provider supported by SubSonic private class CustomDataProvider : MySqlDataProvider { public CustomDataProvider(string connectionString) { DefaultConnectionString = connectionString; } public override string Name { get { return “WebShop”; // Database Name does not change often!! } } }


Rob Conery’s Blog: New SubSonic Provider: LOLCode.NET
http://blog.wekeroad.com/2007/10/26/new-subsonic-provider-lolcodenet/
SubSonic


Rob Conery’s Blog: SubSonic: 2.1 (Pakala) Preview, Part 2
http://blog.wekeroad.com/2008/01/16/subsonic-21-pakala-preview-part-2/



System.Configuration.DefaultSection
http://www.dotnettech.net/BCL/CSharp/System.Configuration.DefaultSection/Class.aspx



 

原创文章,转载请注明: 转载自YippeeSoft开心软件

本文链接地址: SubSonic dynamic connections

历史博文

标签: