yubaolee
2021-04-21 18:02:01 +08:00
parent d4894b5ba3
commit b278a1ec10
19 changed files with 124 additions and 65 deletions

View File

@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System.Linq;
using Autofac;
using Infrastructure;
using Microsoft.AspNetCore.Builder;
@@ -69,9 +70,11 @@ namespace OpenAuth.IdentityServer
//映射配置文件
services.Configure<AppSetting>(Configuration.GetSection("AppSetting"));
//在startup里面只能通过这种方式获取到appsettings里面的值不能用IOptions😰
var dbType = ((ConfigurationSection) Configuration.GetSection("AppSetting:DbType")).Value;
var dbtypes = ((ConfigurationSection)Configuration.GetSection("AppSetting:DbTypes")).GetChildren()
.ToDictionary(x => x.Key, x => x.Value);
var dbType = dbtypes["OpenAuthDBContext"];
if (dbType == Define.DBTYPE_SQLSERVER)
{
services.AddDbContext<OpenAuthDBContext>(options =>

View File

@@ -9,6 +9,8 @@
"OpenAuthDBContext": "server=127.0.0.1;user id=root;database=openauthdb;password=000000" //my sql
},
"AppSetting": {
"DbType": "MySql" //数据库类型SqlServer/MySql
"DbTypes": {
"OpenAuthDBContext":"MySql" //数据库类型SqlServer、MySql、Oracle
}
}
}

View File

@@ -10,6 +10,8 @@
//"OpenAuthDBContext": "server=127.0.0.1;user id=root;database=openauthdb;password=000000" //my sql
},
"AppSetting": {
"DbType": "SqlServer" //数据库类型SqlServer/MySql
"DbTypes": {
"OpenAuthDBContext":"SqlServer" //数据库类型SqlServer、MySql、Oracle
}
}
}