Skip to content

Commit

Permalink
Change the location DbConnectionString settings in appsettings for in…
Browse files Browse the repository at this point in the history
…stalled database (settings only for advanced administrators)
  • Loading branch information
support committed Jul 24, 2023
1 parent 5d865f6 commit de93e99
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/Core/Grand.Infrastructure/Configuration/AdvancedConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
{
public class AdvancedConfig
{
public string DbConnectionString { get; set; }
public int DbProvider { get; set; }
public string InstalledPlugins { get; set; }

}
}
7 changes: 7 additions & 0 deletions src/Core/Grand.Infrastructure/Configuration/DatabaseConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ public class DatabaseConfig
/// Gets or sets a value indicating whether use LiteDB database (only for installation process)
/// </summary>
public string LiteDbConnectionString { get; set; }

/// <summary>
/// Gets or sets a value indicating whether use connection string for database (only for installed databases)
/// </summary>
public string DbConnectionString { get; set; }
public int DbProvider { get; set; }

}
}
8 changes: 4 additions & 4 deletions src/Core/Grand.Infrastructure/StartupBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public static class StartupBase
/// </summary>
private static void InitDatabase(IServiceCollection services, IConfiguration configuration)
{
var advancedConfig = services.StartupConfig<AdvancedConfig>(configuration.GetSection("Advanced"));
if (!string.IsNullOrEmpty(advancedConfig.DbConnectionString))
var dbConfig = services.StartupConfig<DatabaseConfig>(configuration.GetSection("Database"));
if (!string.IsNullOrEmpty(dbConfig.DbConnectionString))
{
DataSettingsManager.LoadDataSettings(new DataSettings {
ConnectionString = advancedConfig.DbConnectionString,
DbProvider = (DbProvider)advancedConfig.DbProvider
ConnectionString = dbConfig.DbConnectionString,
DbProvider = (DbProvider)dbConfig.DbProvider
});
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Web/Grand.Web/App_Data/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
//LiteDB database as a singleton service in the application
"Singleton": true,
//Init connection string - it's required only for the installation process!
"LiteDbConnectionString": "Filename=App_Data/database.db"
"LiteDbConnectionString": "Filename=App_Data/database.db",
//only for advanced users, allow to set ConnectionString for MongoDb
"DbConnectionString": "",
"DbProvider": 0
},

"Security": {
Expand Down Expand Up @@ -242,8 +245,6 @@
"UseSwagger": false,
//Settings only for advanced users
"Advanced": {
"DbConnectionString": "",
"DbProvider": 0,
//separator comma
"InstalledPlugins": ""
},
Expand Down

0 comments on commit de93e99

Please sign in to comment.