我需要在 appsettings.json 中的两个位置使用数据库连接字符串。
是否可以在 json 文件中引入公共变量或 json-path 相关引用以避免潜在的问题?
如果能在不接触 C# 代码的情况下拥有它,那就太棒了。
{
...
"ConnectionStrings": {
"Default": "Host=localhost;Database=db;Port=5432;Username=postgres;Password=postgres"
},
"Nlog": {
"targets": {
"database": {
"type": "Database",
"dbProvider": "Npgsql.NpgsqlConnection, Npgsql",
"connectionString": "Host=localhost;Database=db;Port=5432;Username=postgres;Password=postgres",
...
}
}
...
}
Run Code Online (Sandbox Code Playgroud)