刘磊
2025-06-09 dabbcafc629ef87d11ba55ef8cc1cdc776c047d8
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
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.DB;
using WIDESEA_Core.Seed;
 
namespace WIDESEA_Core.Helper
{
    public class SqlSugarHelper
    {
        //多库情况下使用说明:
        //如果是固定多库可以传 new SqlSugarScope(List<ConnectionConfig>,db=>{}) 文档:多租户
        //如果是不固定多库 可以看文档Saas分库
        //用单例模式
      //  public static SqlSugarScope DbWCS = new SqlSugarScope(new ConnectionConfig()
      //  {
      //      //ConnectionString = DBContext.GetMainConnectionDb().Connection,
      //      ConnectionString = AppSettings.app(MainDb.ConnectionStringWCS),
      //      DbType = DbType.SqlServer,//数据库类型
      //      IsAutoCloseConnection = true //不设成true要手动close
      //  },
      //db =>
      //    { 
      //    });
 
        public static SqlSugarScope DbWMS = new SqlSugarScope(new ConnectionConfig()
        {
            ConnectionString = DBContext.GetMainConnectionDb().Connection,
            //ConnectionString = AppSettings.app(MainDb.ConnectionStringWCS),
            DbType = DbType.SqlServer,//数据库类型
            IsAutoCloseConnection = true //不设成true要手动close
        },
      db =>
      {
      });
    }
}