using System; using System.Collections.Generic; using System.Linq; using MySystem.MainModels; namespace MySystem { public class PosMachinesTwoDbconn { public readonly static PosMachinesTwoDbconn Instance = new PosMachinesTwoDbconn(); #region 获取单个字段 public PosMachinesTwo Get(int Id) { // string key = "PosMachinesTwo:" + Id; // if (RedisDbconn.Instance.Exists(key)) // { // PosMachinesTwo obj = RedisDbconn.Instance.Get(key); // if (obj != null) // { // return obj; // } // } WebCMSEntities db = new WebCMSEntities(); PosMachinesTwo order = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Id); if (order != null) { // RedisDbconn.Instance.Set(key, order); // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400)); } db.Dispose(); return order; } public PosMachinesTwo Get(string PosSn) { string key = "PosMachinesTwo:" + PosSn; if (RedisDbconn.Instance.Exists(key)) { PosMachinesTwo obj = RedisDbconn.Instance.Get(key); if (obj != null) { return obj; } } WebCMSEntities db = new WebCMSEntities(); PosMachinesTwo order = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn); if (order != null) { RedisDbconn.Instance.Set(key, order); RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400)); } return order; } #endregion } }