移动系统liao
2025-05-01 a247547df86f0fad8f03aebb91de68d3f2bc7918
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Furion;
using SqlSugar;
using System.Collections.Generic;
 
namespace cylsg.Core;
 
/// <summary>
/// 数据库上下文对象
/// </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")
        connectionConfigs
        , db =>
        {
            // 这里配置全局事件,比如拦截执行 SQL
            var a = 100;
        });
}