using SqlSugar;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace BLWWS_BLL
{
    public static class SqlSugarBase
    {
        public static SqlSugarClient GesmartDb()
        {
            SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = "Server=blv-cloud-db.mysql.rds.aliyuncs.com;Database=Face;Uid=blv_rcu;Pwd=fnadiaJDIJ7546;charset=utf8;port=3307;",
                DbType = SqlSugar.DbType.MySql,
                InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
                IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了
            });
            //用来打印Sql方便调式
            Db.Aop.OnLogExecuting = (sql, pars) =>
            {
                Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
                Debug.WriteLine(sql);
            };
            return Db;
        }


    }
}
