DbConnectionOptions.cs 2.8 KB

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