| | |
| | | /// </summary> |
| | | public static class DbContext |
| | | { |
| | | public static List<ConnectionConfig> connectionConfigs |
| | | { |
| | | get |
| | | { |
| | | var list = App.GetConfig<List<ConnectionConfig>>("ConnectionConfigs"); |
| | | foreach (var config in list) |
| | | { |
| | | config.ConfigureExternalServices = new ConfigureExternalServices() |
| | | { |
| | | DataInfoCacheService = new SqlSugarRedisCache() |
| | | }; |
| | | } |
| | | return list; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// SqlSugar 数据库实例 |
| | | /// </summary> |
| | | public static readonly SqlSugarScope Instance = new( |
| | | // 读取 appsettings.json 中的 ConnectionConfigs 配置节点 |
| | | App.GetConfig<List<ConnectionConfig>>("ConnectionConfigs") |
| | | //App.GetConfig<List<ConnectionConfig>>("ConnectionConfigs") |
| | | connectionConfigs |
| | | , db => |
| | | { |
| | | // 这里配置全局事件,比如拦截执行 SQL |