DBConfig.cs 747 B

1234567891011121314151617181920212223242526
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. namespace WZExport.Models
  8. {
  9. public class DBConfig
  10. {
  11. [DisplayName("数据库")]
  12. public string DBName { get; set; }
  13. [DisplayName("连接字符串")]
  14. public string ConnectStr { get; set; }
  15. public bool Choose { get; set; }
  16. public static string GetChooseConnet()
  17. {
  18. string configStr = System.IO.File.ReadAllText("dBConfig.json");
  19. var dBConfigs = JsonConvert.DeserializeObject<List<DBConfig>>(configStr);
  20. return dBConfigs.FirstOrDefault(config => config.Choose == true).ConnectStr;
  21. }
  22. }
  23. }