I created my own CMS for my own use. Currently, I am already launching 3 websites using my CMS. and will continue to add.
since all websites always use the same version of my CMS, I just need to create one administration site to manage them all.
I am using Subsonic 2.x for the data access layer. on the administration website I have to put all connectionStrings
<SubSonicService defaultProvider="firstSql">
<providers>
<clear/>
<add name="firstSql" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="first" generatedNamespace="firstSql"/>
<add name="secondSql" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="second" generatedNamespace="second"/>
<add name="thirdSql" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="third" generatedNamespace="thirdSql"/>
</providers>
</SubSonicService>
<connectionStrings>
<clear/>
<add name="first" connectionString="Data Source=123.123.12.3;Initial Catalog=first;User ID=first;Password=first" providerName="System.Data.SqlClient"/>
<add name="second" connectionString="Data Source=123.123.12.3;Initial Catalog=second;User ID=second;Password=second" providerName="System.Data.SqlClient"/>
<add name="third" connectionString="Data Source=123.123.12.3;Initial Catalog=third;User ID=third;Password=third" providerName="System.Data.SqlClient"/>
</connectionStrings>
here is the ugly code
switch(sitename){
case "first":
var comment1 = new firstSql.Comment(id);
comment1.Accepted = true;
comment1.Save();
break;
case "second":
var comment2 = new secondSql.Comment(id);
comment2.Accepted = true;
comment2.Save();
break;
case "third":
var comment3 = new thirdSql.Comment(id);
comment3.Accepted = true;
comment3.Save();
break;
}
I'm looking for a way to do it like this
cmsSql.ConnectionString( getConnectionString(sitename) );
var comment = new cmsSql.Comment(id);
comment.Accepted = true;
comment.Save();
Is there any ORM solution that supports this?
Or
Do you know any workaround for this with the current ORM (Subsonic 2.x)?
UPDATE: add another example
cmsSql.ConnectionString( DB_ConString_WebsiteABC );
var comment = new cmsSql.Comment(id);
comment.Accepted = true;
comment.Save();
cmsSql.ConnectionString( DB_ConString_AnotherWebsiteThatSimilarToABC );
var comment = new cmsSql.Comment(id);
comment.Accepted = true;
comment.Save(); // saved to another database
source
share