OrdersDbconn.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.MainModels;
  5. namespace MySystem
  6. {
  7. public class OrdersDbconn
  8. {
  9. public readonly static OrdersDbconn Instance = new OrdersDbconn();
  10. #region 获取单个字段
  11. public Orders Get(int Id)
  12. {
  13. // string key = "Orders:" + Id;
  14. // if (RedisDbconn.Instance.Exists(key))
  15. // {
  16. // Orders obj = RedisDbconn.Instance.Get<Orders>(key);
  17. // if (obj != null)
  18. // {
  19. // return obj;
  20. // }
  21. // }
  22. WebCMSEntities db = new WebCMSEntities();
  23. Orders order = db.Orders.FirstOrDefault(m => m.Id == Id);
  24. if (order != null)
  25. {
  26. // RedisDbconn.Instance.Set(key, order);
  27. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400));
  28. }
  29. db.Dispose();
  30. return order;
  31. }
  32. #endregion
  33. }
  34. }