using HKCardOUT.Helper;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace HKCardOUT.Logic
{
    public class DbContext
    {
        public static SqlSugarScope Context = new(new ConnectionConfig()
        {
            ConnectionString = DataBus.ConnectionString,//连接符字串
            DbType = DbType.Sqlite,//数据库类型
            IsAutoCloseConnection = true //不设成true要手动close
        }, db =>
        {
            db.Aop.OnLogExecuting = (sql, pars) =>
            {

            };
        });

        public static void InitTable()
        {
            var Tables = Assembly.GetAssembly(typeof(DbContext))
                  .GetTypes().Where(t => t.BaseType == typeof(BaseEntity)).ToArray();
            Context.CodeFirst.InitTables(Tables);
        }
    }
}
