using System; using System.Collections.Generic; using System.Linq; using MySystem.Models.Main; namespace MySystem { public class MachineForQrCodeDbconn { public readonly static MachineForQrCodeDbconn Instance = new MachineForQrCodeDbconn(); #region 获取单个字段 public MachineForQrCode Get(string DataId) { WebCMSEntities db = new WebCMSEntities(); MachineForQrCode order = db.MachineForQrCode.FirstOrDefault(m => m.DataId == DataId); if (order != null) { } return order; } #endregion #region 获取列表 public List GetList(int MerchantId, int pageNum = 1, int pageSize = 10) { // string key = "MachineForQrCodeList:" + MerchantId; // List list = new List(); // if (RedisDbconn.Instance.Exists(key)) // { // list = RedisDbconn.Instance.GetList(key, pageNum, pageSize); // if (list.Count > 0) // { // return list; // } // } WebCMSEntities db = new WebCMSEntities(); List newlist = new List(); var mysqllist = db.MachineForQrCode.Where(m => m.MerchantId == MerchantId && m.SnNo != m.MachineSnNo).ToList(); if (mysqllist.Count > 0) { foreach (MachineForQrCode sub in mysqllist) { newlist.Add(sub); } // RedisDbconn.Instance.Clear(key); // foreach (MachineForQrCode sub in newlist) // { // RedisDbconn.Instance.AddRightList(key, sub); // } // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400)); } db.Dispose(); return newlist; } #endregion } }