You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.1 KiB

2 years ago
  1. using Newtonsoft.Json;
  2. using System.Collections.Generic;
  3. namespace SqlSugar
  4. {
  5. public class ConnectionConfig
  6. {
  7. /// <summary>
  8. ///DbType.SqlServer Or Other
  9. /// </summary>
  10. public DbType DbType { get; set; }
  11. /// <summary>
  12. ///Database Connection string
  13. /// </summary>
  14. public string ConnectionString { get; set; }
  15. /// <summary>
  16. /// true does not need to close the connection
  17. /// </summary>
  18. public bool IsAutoCloseConnection { get; set; }
  19. /// <summary>
  20. /// Default SystemTable,If you do not have system table permissions, use attribute
  21. /// </summary>
  22. public InitKeyType InitKeyType = InitKeyType.SystemTable;
  23. /// <summary>
  24. ///If true, there is only one connection instance in the same thread within the same connection string
  25. /// </summary>
  26. public bool IsShardSameThread { get; set; }
  27. /// <summary>
  28. /// Configure External Services replace default services,For example, Redis storage
  29. /// </summary>
  30. [JsonIgnore]
  31. public ConfigureExternalServices ConfigureExternalServices = _DefaultServices;
  32. private static ConfigureExternalServices _DefaultServices = new ConfigureExternalServices();
  33. /// <summary>
  34. /// If SlaveConnectionStrings has value,ConnectionString is write operation, SlaveConnectionStrings is read operation.
  35. /// All operations within a transaction is ConnectionString
  36. /// </summary>
  37. public List<SlaveConnectionConfig> SlaveConnectionConfigs { get; set; }
  38. /// <summary>
  39. /// More Gobal Settings
  40. /// </summary>
  41. public ConnMoreSettings MoreSettings { get; set; }
  42. }
  43. public class ConfigureExternalServices
  44. {
  45. private ISerializeService _SerializeService;
  46. private ICacheService _ReflectionInoCache;
  47. private ICacheService _DataInfoCache;
  48. public ISerializeService SerializeService
  49. {
  50. get
  51. {
  52. if (_SerializeService == null)
  53. return DefaultServices.Serialize;
  54. else
  55. return _SerializeService;
  56. }
  57. set{ _SerializeService = value;}
  58. }
  59. public ICacheService ReflectionInoCacheService
  60. {
  61. get
  62. {
  63. if (_ReflectionInoCache == null)
  64. return DefaultServices.ReflectionInoCache;
  65. else
  66. return _ReflectionInoCache;
  67. }
  68. set{_ReflectionInoCache = value;}
  69. }
  70. public ICacheService DataInfoCacheService
  71. {
  72. get
  73. {
  74. if (_DataInfoCache == null)
  75. return DefaultServices.DataInoCache;
  76. else
  77. return _DataInfoCache;
  78. }
  79. set { _DataInfoCache = value; }
  80. }
  81. public List<SqlFuncExternal> SqlFuncServices { get; set; }
  82. public List<KeyValuePair<string, CSharpDataType>> AppendDataReaderTypeMappings { get; set; }
  83. }
  84. }