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
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.