One code base, many db's... how to handle connection strings??

One code base, many db's... how to handle connection strings??

Old forum URL: forums.lhotka.net/forums/t/2140.aspx


rhinoishere posted on Monday, January 15, 2007

As the subject says, where I work we have one code base.  Many customers with different databases use this same code base, so obviously we have to utilize a different connection string based upon who is logged in at any given time. 

How does one prevent having to pass the connection string into the business object in that case? 

So, in other words, you end up with code like this:

Customer cust = Customer.GetCustomer(sConnectString, custId);

Unfortunately, I don't think there is any way around this. Am I wrong?

thanks

ajj3085 replied on Monday, January 15, 2007

Where is the information that maps a username to a database connection?  I would think you'd use that, and then stick the resulting connection string into Csla.ApplicationContext.

Andy

hurcane replied on Monday, January 15, 2007

Our customers typically have two databases, a "live" database and a "training" database. We have created a custom user/principal objects and included a property to retrieve the connection string. The connection string is assigned during the login process and stays associated with that user as long as they log in.

Instead of passing the connection string around through parameters, all business objects get it from the user object, which is automatically passed from the client.

ajj3085 replied on Tuesday, January 16, 2007

So the BO decides the connection string?  It should probably just put it in Csla.ApplicationContext then, and your BOs can pull the data from there.

Copyright (c) Marimer LLC