1
pulg
2025-06-17 03f92b99d7f00b728dccd409863c38d1191a4c60
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
using HH.WCS.Hexafluo.util;
using HH.WCS.SJML.Dto;
using HH.WCS.ZCQTJ.Entitys;
using Newtonsoft.Json;
using SqlSugar;
using System;
 
namespace HH.WCS.ZCQTJ.util
{
    public class SqlServerList
    {
        public OperateResult SqlConnect(string ConfigId)
        {
            var oop = SqlSugarHelper.conn;
            if (oop.FindAll(e => e.ConfigId.ToString() == ConfigId).Count == 0)
            {
                //查询表 然后加入到连接池里
                var Alone = SqlSugarHelper.Db.Queryable<SqlCountEntitys>().Where(e => e.ConfigId == ConfigId)?.First();
                if (Alone != null)
                {
                    SqlSugarHelper.conn.Add(new ConnectionConfig()
                    {
                        ConfigId = Alone.ConfigId,
                        DbType = DbType.SqlServer,
                        ConnectionString = Alone.ConnectionString,
                        IsAutoCloseConnection = true,
                        InitKeyType = InitKeyType.Attribute
                    });
                }
            }
 
            return OperateResult.Succeed();
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>
        public OperateResult SqlConnectC()
        {
            var Alone = SqlSugarHelper.Db.Queryable<SqlCountEntitys>().ToList();
            foreach (var item in Alone)
            {
                SqlSugarHelper.conn.Add(new ConnectionConfig()
                {
                    ConfigId = item.ConfigId,
                    DbType = DbType.SqlServer,
                    ConnectionString = item.ConnectionString,
                    IsAutoCloseConnection = true,
                    InitKeyType = InitKeyType.Attribute
                });
            }
            foreach (var item in SqlSugarHelper.conn)
            {
                Console.WriteLine($"sql连接池 {JsonConvert.SerializeObject(item)}");
            }
            //查询表 然后吧sql语句加到连接池中
            return OperateResult.Succeed();
        }
    }
}