SubSonic 2.2: DefaultConnectionString

subsonic

I may be a bit over my head here – but hopefully someone can point me in the right direction.

Using the latest SOURCE files for SubSonic 2 – I need to be able to manipulate the CONNECTIONSTRING for specific requests based on the USER.

I thought I could modify DefaultConnectionString is DataProvider.cs – but HttpContext.Current ALWAYS seems to be null when that property is called (even when it is through a http request.)

When is that called by SubSonic? I'm assuming it is at a point when the page lifecycle DOESN'T exist and therefore the HTTPCONTEXT/PROFILE data is always missing.

Is there any way to work around this? Basically I have several identical structure databases I wish to access using SubSonic (same structures) and I want to choose the DB to use based on the current user's profile, any suggestions?

Best Answer

You can specify multiple providers in your config and then choose which to use at runtime. See the following question for details of how:

Separate Read/Write Connection for SubSonic

Related Topic