R – SubSonic 2.1 using multiple databases

connection-stringdatabasesubsonic

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?

Best Answer

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);