25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
916 B

  1. using HKCardOUT.Helper;
  2. using SqlSugar;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Reflection;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace HKCardOUT.Logic
  10. {
  11. public class DbContext
  12. {
  13. public static SqlSugarScope Context = new(new ConnectionConfig()
  14. {
  15. ConnectionString = DataBus.ConnectionString,//连接符字串
  16. DbType = DbType.Sqlite,//数据库类型
  17. IsAutoCloseConnection = true //不设成true要手动close
  18. }, db =>
  19. {
  20. db.Aop.OnLogExecuting = (sql, pars) =>
  21. {
  22. };
  23. });
  24. public static void InitTable()
  25. {
  26. var Tables = Assembly.GetAssembly(typeof(DbContext))
  27. .GetTypes().Where(t => t.BaseType == typeof(BaseEntity)).ToArray();
  28. Context.CodeFirst.InitTables(Tables);
  29. }
  30. }
  31. }