| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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<PosMachinesTwo>(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<PosMachinesTwo>(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
- }
- }
|