DB.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 void CreateTableIfNotExisted(string table, Dictionary<string, Type> columns, bool addPID, string primaryKey)
  17. {
  18. if (Instance != null)
  19. Instance.CreateTableIfNotExisted(table, columns, addPID, primaryKey);
  20. }
  21. public static void CreateTableIndexIfNotExisted(string table, string index, string sql)
  22. {
  23. if (Instance != null)
  24. Instance.CreateTableIndexIfNotExisted(table, index, sql);
  25. }
  26. public static void CreateTableColumn(string table, Dictionary<string, Type> columns )
  27. {
  28. if (Instance != null)
  29. Instance.CreateTableColumn(table, columns );
  30. }
  31. public static DataSet ExecuteDataset(string cmdText, params object[] p)
  32. {
  33. if (Instance != null)
  34. return Instance.ExecuteDataset(cmdText, p);
  35. return null;
  36. }
  37. public static int GetCount(string cmdText, params object[] p)
  38. {
  39. if (Instance != null)
  40. return Instance.GetCount(cmdText, p);
  41. return 0;
  42. }
  43. }
  44. }