48 lines
2.0 KiB
C#
48 lines
2.0 KiB
C#
|
|
using SqlSugar;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Diagnostics;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace Models
|
|||
|
|
{
|
|||
|
|
public class SqljohaoBase
|
|||
|
|
{
|
|||
|
|
public static object S = new object();
|
|||
|
|
//public static string sql = "Server=uts-svr2.qicp.net;Database=uts_ZongQing;Uid=uts_manager;Pwd=WoUts*#082k;charset=utf8;port=3307;AllowLoadLocalInfile=true;";
|
|||
|
|
public static string sql = "Server=db.uts-data.com;Database=uts_johao;Uid=uts_manager;Pwd=WoUts*#082k;charset=utf8;port=3307;;AllowLoadLocalInfile=true;";
|
|||
|
|
public static SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()
|
|||
|
|
{
|
|||
|
|
DbType = SqlSugar.DbType.MySql,
|
|||
|
|
ConnectionString = sql,
|
|||
|
|
IsAutoCloseConnection = true
|
|||
|
|
},
|
|||
|
|
db =>
|
|||
|
|
{
|
|||
|
|
lock (S)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//string s3 = AppDomain.CurrentDomain.BaseDirectory;
|
|||
|
|
//db.DbMaintenance.CreateDatabase(); //个别数据库不支持
|
|||
|
|
//Type[] types = Assembly
|
|||
|
|
//.LoadFrom($@"{s3}\bin\Models.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
|
|||
|
|
//.GetTypes().Where(it => it.FullName.Contains("Models.ModelItems."))//命名空间过滤,当然你也可以写其他条件过滤
|
|||
|
|
//.ToArray();//断点调试一下是不是需要的Type,不是需要的在进行过滤
|
|||
|
|
//db.CodeFirst.SetStringDefaultLength(200).InitTables(types);//根据types创建表
|
|||
|
|
db.Aop.OnLogExecuting = (s, p) =>
|
|||
|
|
{
|
|||
|
|
Debug.WriteLine(s);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
//string ret = $"{s3}\\App_Data\\configs\\sqlView.txt";
|
|||
|
|
//string ret1 = $"{s3}\\App_Data\\configs\\ccgc.txt";
|
|||
|
|
//string url = File.ReadAllText(ret, Encoding.UTF8);
|
|||
|
|
//string url1 = File.ReadAllText(ret1, Encoding.UTF8);
|
|||
|
|
//Db.Ado.ExecuteCommand(url);
|
|||
|
|
//Db.Ado.ExecuteCommand(url1);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|