123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using MySystem.Models;
- namespace MySystem
- {
- public class AdvertismentDbconn
- {
- public readonly static AdvertismentDbconn Instance = new AdvertismentDbconn();
- #region 获取列表
- public List<Advertisment> GetList(string ColId)
- {
- string key = "AdvertismentList:" + ColId;
- List<Advertisment> list = new List<Advertisment>();
- if (RedisDbconn.Instance.Exists(key))
- {
- list = RedisDbconn.Instance.GetList<Advertisment>(key);
- if (list.Count > 0)
- {
- return list;
- }
- }
- List<Advertisment> newlist = new List<Advertisment>();
- WebCMSEntities db = new WebCMSEntities();
- var mysqllist = db.Advertisment.Where(m => m.ColId == ColId).OrderByDescending(m => m.Sort).OrderByDescending(m => m.Id).ToList();
- if (mysqllist.Count > 0)
- {
- foreach (var sub in mysqllist)
- {
- newlist.Add(sub);
- }
- RedisDbconn.Instance.Clear(key);
- foreach (Advertisment sub in newlist)
- {
- RedisDbconn.Instance.AddRightList(key, sub);
- }
- }
- db.Dispose();
- return newlist;
- }
- #endregion
- }
- }
|