12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 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<MachineForQrCode> GetList(int MerchantId, int pageNum = 1, int pageSize = 10)
- {
- // string key = "MachineForQrCodeList:" + MerchantId;
- // List<MachineForQrCode> list = new List<MachineForQrCode>();
- // if (RedisDbconn.Instance.Exists(key))
- // {
- // list = RedisDbconn.Instance.GetList<MachineForQrCode>(key, pageNum, pageSize);
- // if (list.Count > 0)
- // {
- // return list;
- // }
- // }
- WebCMSEntities db = new WebCMSEntities();
- List<MachineForQrCode> newlist = new List<MachineForQrCode>();
- 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
- }
- }
|