views:

265

answers:

3

Hello,

I want to use SubSonic 2.1 to connect to 2 different databases (each having different tables). What is the best way to do this? What is the best way to seperate the generated code between the 2 databases and how can I switch between databases?

+3  A: 

Hi,

I think this has already been answered here: http://stackoverflow.com/questions/968391/subsonic-dynamic-connections

nachojammers
+1  A: 

I do this on quite a few projects with 2.2 and find that i dont need to impliment the "shared connection scope"

I set my class library up with the databases, give all the databases all a different name and namespace and gen it.

Then when i need to call them i am specific about what i am calling

ie

SqlQuery q = new Select()
             .From(Tables.Products);

becomes

SqlQuery q = new Select()
             .From(Data.Database1.Tables.Products);

if its still failing i've found i can do the following

SqlQuery q = Data.Database1.DB.Select()
             .From(Data.Database1.Tables.Products);
Doug
A: 

Hey Doug could you please give me an example of the above code? In which namespace is the Data object (from Data.Database1) and do you need to set multiple providers in the web.config because you need to connect to multiple databases?

Jeroen Breuer
Yes, you need to create two different providers in your web.config/app.config
Doug