views:

72

answers:

1

I am adding SubSonic to a legacy application. This application already defines a ConnectionString. Is there a way I can use this connectionstring instead of creating a new Data Provider entry?

I know that one solution is programmatically setting this in the code (i.e. SubSonic.DataService.GetInstance("Name").SetDefaultConnectionString("ConnString") ). However, is there a more elegant solution?

+1  A: 

I think that's the only way to do it. And it might throw an exception if there is no place holder SubSonicService in the config file, I don't remember.

// GetInstance just to initialize subsonic.
DataProvider provider = DataService.GetInstance(subsonicProviderName);

// Set the actual database connection string. 
// Overrides config file setting.
provider.DefaultConnectionString = connectionString;

DataService.Provider = provider;
P a u l