views:

55

answers:

1

Here is the situation.

I am using SubSonic 3 and would like to specify at run time which connection string to use. This a command line application and the connection string name will be specified by the user as a command line argument.

What is the best way to accomplish this?

+1  A: 

Our providers are simply wrappers for connection strings - so anywhere you see "IDataProvider" you can create one using ProviderFactory.GetProvider("CONNECTIONSTRING","DataProvider"). I know that looks like a lot of providers :) but the latter is for the connection string to work - in this case it's a string value and should be "System.Data.SqlClient" or whatever you're using.

This will work with ActiveRecord too - Post.SingleOrDefault(MyProvider, x=>x.ID=id);

Rob Conery
It looks like there are two method signatures to use.Post.FirstOrDefault( string connectionString, string providerName )andpostRecord.Save(IDataProvider provider)So I'll probably create a static singleton which have those 3 parameters I need so I can use them in every call.It would be nice if there was a way to globally change the connection string name so that one did not have to include those parameters in every call.Thanks for the help.
Lance