DbConnectionOptions.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // 麻省理工学院许可证
  2. //
  3. // 版权所有 (c) 2021-2023 zuohuaijun,大名科技(天津)有限公司 联系电话/微信:18020030720 QQ:515096995
  4. //
  5. // 特此免费授予获得本软件的任何人以处理本软件的权利,但须遵守以下条件:在所有副本或重要部分的软件中必须包括上述版权声明和本许可声明。
  6. //
  7. // 软件按“原样”提供,不提供任何形式的明示或暗示的保证,包括但不限于对适销性、适用性和非侵权的保证。
  8. // 在任何情况下,作者或版权持有人均不对任何索赔、损害或其他责任负责,无论是因合同、侵权或其他方式引起的,与软件或其使用或其他交易有关。
  9. namespace Admin.NET.Core;
  10. /// <summary>
  11. /// 数据库配置选项
  12. /// </summary>
  13. public sealed class DbConnectionOptions : IConfigurableOptions<DbConnectionOptions>
  14. {
  15. /// <summary>
  16. /// 启用控制台打印SQL
  17. /// </summary>
  18. public bool EnableConsoleSql { get; set; }
  19. /// <summary>
  20. /// 数据库集合
  21. /// </summary>
  22. public List<DbConnectionConfig> ConnectionConfigs { get; set; }
  23. public void PostConfigure(DbConnectionOptions options, IConfiguration configuration)
  24. {
  25. foreach (var dbConfig in options.ConnectionConfigs)
  26. {
  27. dbConfig.ConfigId ??= SqlSugarConst.MainConfigId;
  28. }
  29. }
  30. }
  31. /// <summary>
  32. /// 数据库连接配置
  33. /// </summary>
  34. public sealed class DbConnectionConfig : ConnectionConfig
  35. {
  36. /// <summary>
  37. /// 数据库设置
  38. /// </summary>
  39. public DbSettings DbSettings { get; set; }
  40. /// <summary>
  41. /// 表设置
  42. /// </summary>
  43. public TableSettings TableSettings { get; set; }
  44. /// <summary>
  45. /// 种子设置
  46. /// </summary>
  47. public SeedSettings SeedSettings { get; set; }
  48. }
  49. /// <summary>
  50. /// 数据库设置
  51. /// </summary>
  52. public sealed class DbSettings
  53. {
  54. /// <summary>
  55. /// 启用库表初始化
  56. /// </summary>
  57. public bool EnableInitDb { get; set; }
  58. /// <summary>
  59. /// 启用库表差异日志
  60. /// </summary>
  61. public bool EnableDiffLog { get; set; }
  62. /// <summary>
  63. /// 启用驼峰转下划线
  64. /// </summary>
  65. public bool EnableUnderLine { get; set; }
  66. }
  67. /// <summary>
  68. /// 表设置
  69. /// </summary>
  70. public sealed class TableSettings
  71. {
  72. /// <summary>
  73. /// 启用表初始化
  74. /// </summary>
  75. public bool EnableInitTable { get; set; }
  76. /// <summary>
  77. /// 启用表增量更新
  78. /// </summary>
  79. public bool EnableIncreTable { get; set; }
  80. }
  81. /// <summary>
  82. /// 种子设置
  83. /// </summary>
  84. public sealed class SeedSettings
  85. {
  86. /// <summary>
  87. /// 启用种子初始化
  88. /// </summary>
  89. public bool EnableInitSeed { get; set; }
  90. /// <summary>
  91. /// 启用种子增量更新
  92. /// </summary>
  93. public bool EnableIncreSeed { get; set; }
  94. }