IORM.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System.Linq.Expressions;
  2. namespace ORM;
  3. public interface IORM : IDisposable
  4. {
  5. bool Initialize(IOrmProvider? notify = null);
  6. bool Open(string connectionString, DbType dbType, bool isAutoConnection = true);
  7. bool CreateDataBase(string dbName);
  8. bool CreateTable<T>(string? tableName = null) where T : class, new();
  9. /// <summary>
  10. /// this Insert Function can insert a single class or IList<T> class
  11. /// </summary>
  12. /// <typeparam name="T"></typeparam>
  13. /// <param name="data"></param>
  14. /// <returns></returns>
  15. bool Insert<T>(T data) where T : class, new();
  16. /// <summary>
  17. /// this Insert Function can insert a single class or IList<T> class
  18. /// </summary>
  19. /// <typeparam name="T"></typeparam>
  20. /// <param name="data"></param>
  21. /// <returns></returns>
  22. bool Insert<T>(string tablename, T data) where T : class, new();
  23. Task<bool> Query<T>(Action<List<T>> results) where T : class, new();
  24. Task<bool> Query<T>(string tableName, Action<List<T>> results) where T : class, new();
  25. Task<bool> Query<T>(Expression<Func<T, bool>> expression, Action<List<T>> results) where T : class, new();
  26. Task<bool> Query<T>(string tableName, Expression<Func<T, bool>> expression, Action<List<T>> results) where T : class, new();
  27. bool AddOrUpdate<T>(string tableName, T data, Expression<Func<T, bool>> expression) where T : class, new();
  28. bool Delete<T>(string tableName, Expression<Func<T, bool>> expression) where T : class, new();
  29. }
  30. public interface IOrmProvider
  31. {
  32. void Log(string log, DateTime dateTime, LogLevel logLevel);
  33. }
  34. public enum LogLevel
  35. {
  36. Info,
  37. Warning,
  38. Error,
  39. Fatal,
  40. Original
  41. }
  42. //Copy from SqlSugar def
  43. public enum DbType
  44. {
  45. MySql = 0,
  46. SqlServer = 1,
  47. Sqlite = 2,
  48. Oracle = 3,
  49. PostgreSQL = 4,
  50. Dm = 5,
  51. Kdbndp = 6,
  52. Oscar = 7,
  53. MySqlConnector = 8,
  54. Access = 9,
  55. OpenGauss = 10,
  56. QuestDB = 11,
  57. HG = 12,
  58. ClickHouse = 13,
  59. GBase = 14,
  60. Odbc = 15,
  61. OceanBaseForOracle = 16,
  62. TDengine = 17,
  63. GaussDB = 18,
  64. OceanBase = 19,
  65. Tidb = 20,
  66. Vastbase = 21,
  67. PolarDB = 22,
  68. Doris = 23,
  69. Xugu = 24,
  70. GoldenDB = 25,
  71. TDSQLForPGODBC = 26,
  72. TDSQL = 27,
  73. HANA = 28,
  74. DB2 = 29,
  75. Custom = 900
  76. }