StationInfoManager.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using DbCommon.BusinessCore.DbCore;
  2. using DbCommon.Enties.DbModels;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace DbCommon.BusinessCore.BaseCore
  9. {
  10. public class StationInfoManager : DbContext<StationInfo>
  11. {
  12. public void Init()
  13. {
  14. //If no exist create datebase
  15. Db.DbMaintenance.CreateDatabase();
  16. if (!Db.DbMaintenance.IsAnyTable("StationInfo", false))
  17. {
  18. //Create tables
  19. Db.CodeFirst.InitTables(typeof(StationInfo));
  20. }
  21. }
  22. public bool UpdateStatus(StationInfo data)
  23. {
  24. return Db.Updateable(data)
  25. .IgnoreColumns("Command", "CountInterval", "CountAlarm", "CountStartTime")
  26. .ExecuteCommand() > 0;
  27. }
  28. public bool UpdateStatus(List<StationInfo> dataList)
  29. {
  30. return Db.Updateable(dataList)
  31. .IgnoreColumns("Command", "CountInterval", "CountAlarm", "CountStartTime")
  32. .ExecuteCommand() > 0;
  33. }
  34. public bool UpdateCommand(StationInfo data)
  35. {
  36. return Db.Updateable(data)
  37. .UpdateColumns(it => new { it.Command })
  38. .ExecuteCommand() > 0;
  39. }
  40. public bool UpdateCountdown(List<StationInfo> dataList)
  41. {
  42. return Db.Updateable(dataList)
  43. .UpdateColumns(it => new { it.CountInterval, it.CountAlarm})
  44. .ExecuteCommand() > 0;
  45. }
  46. public bool UpdateCountStart(List<StationInfo> dataList)
  47. {
  48. return Db.Updateable(dataList)
  49. .UpdateColumns(it => new { it.Command, it.CountStartTime })
  50. .ExecuteCommand() > 0;
  51. }
  52. }
  53. }