DB.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data;
  6. namespace Aitex.Core.RT.DBCore
  7. {
  8. public static class DB
  9. {
  10. public static ICommonDB Instance { set; private get; }
  11. public static void Insert(string sql)
  12. {
  13. if (Instance != null)
  14. Instance.Insert(sql);
  15. }
  16. public static int SyncUpdate(string sql)
  17. {
  18. if (Instance != null)
  19. return Instance.SyncUpdate(sql);
  20. else
  21. return 0;
  22. }
  23. public static void Update(string sql)
  24. {
  25. if (Instance != null)
  26. Instance.Update(sql);
  27. }
  28. public static int SyncInsert(string sql)
  29. {
  30. if (Instance != null)
  31. return Instance.SyncInsert(sql);
  32. else
  33. return 0;
  34. }
  35. public static void CreateTableIfNotExisted(string table, Dictionary<string, Type> columns, bool addPID, string primaryKey)
  36. {
  37. if (Instance != null)
  38. Instance.CreateTableIfNotExisted(table, columns, addPID, primaryKey);
  39. }
  40. public static void CreateTableIndexIfNotExisted(string table, string index, string sql)
  41. {
  42. if (Instance != null)
  43. Instance.CreateTableIndexIfNotExisted(table, index, sql);
  44. }
  45. public static void CreateTableColumn(string table, Dictionary<string, Type> columns)
  46. {
  47. if (Instance != null)
  48. Instance.CreateTableColumn(table, columns);
  49. }
  50. public static DataSet ExecuteDataset(string cmdText, params object[] p)
  51. {
  52. if (Instance != null)
  53. return Instance.ExecuteDataset(cmdText, p);
  54. return null;
  55. }
  56. }
  57. }