Question

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?

Was it helpful?

Solution

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top