lixiaojun
2024-07-11 da1c001309ed262c55514633490ab8c1b8f68916
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
namespace Yw.Bimface
{
    internal class ConfigHelper
    {
 
        /// <summary>
        /// 默认连接配置
        /// </summary>
        internal static ConnectionConfig DefaultConnectionConfig
        {
            get
            {
                ConnectionConfig connectConfig = null;
                switch (BimfaceParasHelper.Bimface.DataBase.DbType)
                {
                    case DbType.PostgreSql:
                        {
                            connectConfig = PostgreSqlConnectionConfig;
                        }
                        break;
                    case DbType.SQLite:
                        {
                            connectConfig = SQLiteConnectionConfig;
                        }
                        break;
                    default: break;
                }
                return connectConfig;
            }
        }
 
        /// <summary>
        /// PostgreSql连接配置
        /// </summary>
        internal static ConnectionConfig PostgreSqlConnectionConfig
        {
            get
            {
                //SnowFlakeSingle.WorkId = Settings.SqlSugar.SnowFlakeWorkId; 不同机器配置的唯一数字; // 单服务器不需要指定
                return new ConnectionConfig()
                {
                    DbType = SqlSugar.DbType.PostgreSQL,//数据库类型
                    ConnectionString = BimfaceParasHelper.Bimface.DataBase.PostgreSql.ConnectString,
                    IsAutoCloseConnection = true,//是否自动关闭
                    MoreSettings = new ConnMoreSettings()
                    {
                        //PgSqlIsAutoToLower = false //数据库存在大写字段的 ,需要把这个设为false ,并且实体和字段名称要一样
                    },
                    AopEvents = new AopEvents
                    {
                        OnLogExecuting = (sql, p) =>
                        {
                            // var sqlString = UtilMethods.GetNativeSql(sql, p);
                            //LogHelper.Debug(sqlString);
                            // Console.WriteLine(sql);
                        }
                    }
                };
            }
        }
 
        /// <summary>
        /// SQLite连接配置
        /// </summary>
        internal static ConnectionConfig SQLiteConnectionConfig
        {
            get
            {
                //SnowFlakeSingle.WorkId = Settings.SqlSugar.SnowFlakeWorkId; 不同机器配置的唯一数字; // 单服务器不需要指定
                return new ConnectionConfig()
                {
                    DbType = SqlSugar.DbType.Sqlite,//数据库类型
                    ConnectionString = BimfaceParasHelper.Bimface.DataBase.SQLite.ConnectString,
                    IsAutoCloseConnection = true,//是否自动关闭
                    MoreSettings = new ConnMoreSettings()
                    {
                        //PgSqlIsAutoToLower = false //数据库存在大写字段的 ,需要把这个设为false ,并且实体和字段名称要一样
                    },
                    AopEvents = new AopEvents
                    {
                        OnLogExecuting = (sql, p) =>
                        {
                            // var sqlString = UtilMethods.GetNativeSql(sql, p);
                            //LogHelper.Debug(sqlString);
                            // Console.WriteLine(sql);
                        }
                    }
                };
            }
        }
 
 
 
 
 
 
 
 
 
 
 
 
    }
}