DbCommandFactory.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Core.LgMes.Client.lgDbMgt
  6. {
  7. /// <summary>
  8. /// 入口类,根据db类型返回调用2.5还是三期
  9. /// 采用工厂方法模式获取db实例
  10. /// </summary>
  11. public class DbCommandFactory
  12. {
  13. public static IDbCommand createDbCommand(DbCommandType type)
  14. {
  15. IDbCommand commond = null;
  16. switch (type)
  17. {
  18. case DbCommandType.Ejgz:
  19. commond = new DbLgEjgzFactory().createDbCommand();
  20. break;
  21. case DbCommandType.TqMes:
  22. commond = new DbLg3qMesFactory().createDbCommand();
  23. break;
  24. default:
  25. commond = new DbLgEjgzFactory().createDbCommand();
  26. break;
  27. }
  28. return commond;
  29. }
  30. /// <summary>
  31. /// 默认返回2.5级数据库
  32. /// </summary>
  33. /// <returns></returns>
  34. public static IDbCommand createDbCommand()
  35. {
  36. return new DbLgEjgzFactory().createDbCommand();
  37. }
  38. }
  39. }