DalProductData.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using ProjectBase.Data.BaseDAL.BaseDatabase;
  2. using ProjectBase.Util;
  3. using SIMDP.DAL.IDALSQL;
  4. using SIMDP.Model;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace SIMDP.DAL.DALSQL
  13. {
  14. public class DalProductData : BaseDALSQL<MoProductData>, IDalProductData
  15. {
  16. #region 对象实例及构造函数
  17. public static DalProductData Instance
  18. {
  19. get
  20. {
  21. return new DalProductData();
  22. }
  23. }
  24. public DalProductData() : base("product_data", "data_id")
  25. {
  26. this.sortField = "data_id";
  27. this.isDescending = false;
  28. }
  29. #endregion
  30. /// <summary>
  31. /// 将DataReader的属性值转化为实体类的属性值,返回实体类
  32. /// </summary>
  33. /// <param name="dr">有效的DataReader对象</param>
  34. /// <returns>实体类对象</returns>
  35. protected override MoProductData DataReaderToEntity(IDataReader dataReader)
  36. {
  37. MoProductData info = new MoProductData();
  38. SmartDataReader reader = new SmartDataReader(dataReader);
  39. info.DataId = reader.GetInt64("data_id");
  40. info.RuleId = reader.GetInt64("rule_id");
  41. info.DataValue = reader.GetString("data_value");
  42. info.RuleTime = reader.GetDateTime("rule_time");
  43. info.Batchid = reader.GetString("batchid");
  44. return info;
  45. }
  46. /// <summary>
  47. /// 将实体对象的属性值转化为Hashtable对应的键值
  48. /// </summary>
  49. /// <param name="obj">有效的实体对象</param>
  50. /// <returns>包含键值映射的Hashtable</returns>
  51. protected override Hashtable GetHashByEntity(MoProductData obj)
  52. {
  53. MoProductData info = obj as MoProductData;
  54. Hashtable hash = new Hashtable();
  55. //hash.Add("data_id", info.DataId);
  56. hash.Add("rule_id", info.RuleId);
  57. hash.Add("data_value", info.DataValue);
  58. hash.Add("rule_time", info.RuleTime);
  59. hash.Add("batchid", info.Batchid);
  60. return hash;
  61. }
  62. }
  63. }