mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 01:58:01 +08:00
This commit is contained in:
@@ -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 =>
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user