Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 28,055
- Reaction score
- 17,807
Hi gentleman and ladies. I have a small question which requires some thinking hats and mine is not working today. It's not a train smash this but it is a nice to have (I think). I am attempting to select namespaces of the Database used at runtime. One is SQL the other Postgre
This is I have.
See the bold part. I am hoping to be able to change this with something like this.
Is this possible?
This is I have.
C#:
string configValue = ConfigurationManager.AppSettings["DatabaseType"]; //Either SQLDatabase or PostgreSQL
DatabaseType DBType = (DatabaseType)Enum.Parse(typeof(DatabaseType), configValue);
switch (DBType)
{
case DatabaseType.SqlServer:
builder.RegisterType<[B]SQLDatabase[/B].Repositories.VehicleRepository>().As<IVehicleRepository>();
break;
case DatabaseType.Postgress:
builder.RegisterType<[B]PostgreSQL[/B].Repositories.VehicleRepository>().As<IVehicleRepository>();
break;
}
See the bold part. I am hoping to be able to change this with something like this.
C#:
string configValue = ConfigurationManager.AppSettings["DatabaseType"]; //Either SQLDatabase or PostgreSQL
builder.RegisterType<configValue.Repositories.VehicleRepository>().As<IVehicleRepository>();
Is this possible?