That's a good point, Sloan.
A question though: While I realize the that bypassing the factory of the
EntLibs may not be clean, have you come across a best practice for directly
passing in connection strings without using an app/web.config file? What
I ran into, and the reason I directly use the Database objects, is that our
connection strings are anything but stable and for our framework libraries,
it made more sense to create class pseudo-enumerators and pass them along
rather than change 30+ app/web.config files throughout our enterprise. Make
a change to a library, reroll that library to the 2 servers those apps read
from, and be done. The apps are spread throughout the enterprise, so placing
them in the machine.config (if even possible) didn't even seem as clean of
a solution.
The solution you provide still requires manually editing, re-encrypting,
and rerolling config files to the application sources.
Thanks for the explaination^^.
-dl
--
David R. Longnecker
http://blog.tiredstudent.com
s> I think this will work:
s>
s> <add key="MyPreferredDatabase" value="StagingConnectionString" />
s>
s> <connectionStrings>
s>
s> <add name="DevelopmentConnectionString"
s> connectionString="server=MyDevelopmentServer;database=Northwind;User
s> ID=northwinduser;password=northwindpassword"
s> providerName="System.Data.SqlClient"/>
s>
s> <add name="ProductionConnectionString"
s> connectionString="server=MyProductionServer;database=Northwind;User
s> ID=northwinduser;password=northwindpassword"
s> providerName="System.Data.SqlClient"/>
s>
s> <add name="StagingConnectionString"
s> connectionString="server=MyStagingServer;database=Northwind;User
s> ID=northwinduser;password=northwindpassword"
s> providerName="System.Data.SqlClient"/>
s>
s> </connectionStrings>
s>
s> -----------The Code
s>
s> private Database GetADatabase ( )
s> {
s> string preferredDBName =
s> System.Configuration.ConfigurationManager["MyPreferredDatabase"];
s> Database db = DatabaseFactory.CreateDatabase(preferredDBName);
s>
s> return db;
s>
s> }
s>
s> I think that is what Cowboy was getting at.
s>
s> I don't think grabbing a concrete database (SqlDatabase) is a good
s> solution.
s>
s> s>s> connection
s>s> factory
s>s> System.Configuration.ConfigurationManager.ConnectionStrings[databaseN
s> ame].Co nnectionString);
s>s> simply
s>s> changes;
s>s> GAC
s>s>
http://tiredblogger.wordpress.com/2007/05/06/embedded-connection-stri
s> ngs-for-enterprise-library-30/
s>