IORM.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 Delete<T>(string tableName, Expression<Func<T, bool>> expression) where T : class, new();
  28. }
  29. public interface IOrmProvider
  30. {
  31. void Log(string log, DateTime dateTime, LogLevel logLevel);
  32. }
  33. public enum LogLevel
  34. {
  35. Info,
  36. Warning,
  37. Error,
  38. Fatal,
  39. Original
  40. }
  41. //Copy from SqlSugar def
  42. public enum DbType
  43. {
  44. MySql = 0,
  45. SqlServer = 1,
  46. Sqlite = 2,
  47. Oracle = 3,
  48. PostgreSQL = 4,
  49. Dm = 5,
  50. Kdbndp = 6,
  51. Oscar = 7,
  52. MySqlConnector = 8,
  53. Access = 9,
  54. OpenGauss = 10,
  55. QuestDB = 11,
  56. HG = 12,
  57. ClickHouse = 13,
  58. GBase = 14,
  59. Odbc = 15,
  60. OceanBaseForOracle = 16,
  61. TDengine = 17,
  62. GaussDB = 18,
  63. OceanBase = 19,
  64. Tidb = 20,
  65. Vastbase = 21,
  66. PolarDB = 22,
  67. Doris = 23,
  68. Xugu = 24,
  69. GoldenDB = 25,
  70. TDSQLForPGODBC = 26,
  71. TDSQL = 27,
  72. HANA = 28,
  73. DB2 = 29,
  74. Custom = 900
  75. }