Skip to content

Commit

Permalink
Use hierarchical key to load 'database:engine'
Browse files Browse the repository at this point in the history
  • Loading branch information
ousiax committed Dec 23, 2023
1 parent dd7709a commit cd72b00
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Leo.Web.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public Startup(IConfiguration configuration)

public void ConfigureServices(IServiceCollection services)
{
var dbEngine = Configuration.GetValue<string>("Database.Engine");
if (dbEngine == null || string.Equals(dbEngine, "mssql", StringComparison.OrdinalIgnoreCase))
var dbEngine = Configuration.GetValue<string>("Database:Engine");
if (string.Equals(dbEngine, "mssql", StringComparison.OrdinalIgnoreCase))
{
Leo.Web.Data.SqlServer.ServiceCollectionExtensions.AddDataServices(services);
}
else
else // "sqlite"
{
Leo.Web.Data.SQLite.ServiceCollectionExtensions.AddDataServices(services);
}
Expand Down
1 change: 0 additions & 1 deletion src/Leo.Web.Host/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"Database.Engine": "mssql",
"ConnectionStrings": {
"sqlite": "Data Source=db.web.sqlite",
"mssql": "Data Source=local.io;Initial Catalog=Customers;User ID=sa;Password=<YourStrong@Passw0rd>;;Encrypt=False"
Expand Down
1 change: 1 addition & 0 deletions src/Leo.Wpf.App/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Leo.Wpf.App": {
"commandName": "Project",
"environmentVariables": {
"DATABASE__ENGINE": "mssql",
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://127.0.0.1:5001"
}
Expand Down
1 change: 0 additions & 1 deletion src/Leo.Wpf.App/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"Database.Engine": "mssql",
"ConnectionStrings": {
"sqlite": "Data Source=db.sqlite",
"mssql": "Data Source=local.io;Initial Catalog=Customers;User ID=sa;Password=<YourStrong@Passw0rd>;Encrypt=False"
Expand Down

0 comments on commit cd72b00

Please sign in to comment.