DbConnectionOptions.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. if (string.IsNullOrWhiteSpace(dbConfig.ConfigId))
  28. dbConfig.ConfigId = SqlSugarConst.MainConfigId;
  29. }
  30. }
  31. }
  32. /// <summary>
  33. /// 数据库连接配置
  34. /// </summary>
  35. public sealed class DbConnectionConfig : ConnectionConfig
  36. {
  37. /// <summary>
  38. /// 数据库设置
  39. /// </summary>
  40. public DbSettings DbSettings { get; set; }
  41. /// <summary>
  42. /// 表设置
  43. /// </summary>
  44. public TableSettings TableSettings { get; set; }
  45. /// <summary>
  46. /// 种子设置
  47. /// </summary>
  48. public SeedSettings SeedSettings { get; set; }
  49. }
  50. /// <summary>
  51. /// 数据库设置
  52. /// </summary>
  53. public sealed class DbSettings
  54. {
  55. /// <summary>
  56. /// 启用库表初始化
  57. /// </summary>
  58. public bool EnableInitDb { get; set; }
  59. /// <summary>
  60. /// 启用库表差异日志
  61. /// </summary>
  62. public bool EnableDiffLog { get; set; }
  63. /// <summary>
  64. /// 启用驼峰转下划线
  65. /// </summary>
  66. public bool EnableUnderLine { get; set; }
  67. }
  68. /// <summary>
  69. /// 表设置
  70. /// </summary>
  71. public sealed class TableSettings
  72. {
  73. /// <summary>
  74. /// 启用表初始化
  75. /// </summary>
  76. public bool EnableInitTable { get; set; }
  77. /// <summary>
  78. /// 启用表增量更新
  79. /// </summary>
  80. public bool EnableIncreTable { get; set; }
  81. }
  82. /// <summary>
  83. /// 种子设置
  84. /// </summary>
  85. public sealed class SeedSettings
  86. {
  87. /// <summary>
  88. /// 启用种子初始化
  89. /// </summary>
  90. public bool EnableInitSeed { get; set; }
  91. /// <summary>
  92. /// 启用种子增量更新
  93. /// </summary>
  94. public bool EnableIncreSeed { get; set; }
  95. }