AdvertismentDbconn.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.Models.Models;
  5. namespace MySystem
  6. {
  7. public class AdvertismentDbconn
  8. {
  9. public readonly static AdvertismentDbconn Instance = new AdvertismentDbconn();
  10. #region 获取列表
  11. public List<Advertisment> GetList(string ColId)
  12. {
  13. // string key = "AdvertismentList:" + ColId;
  14. // List<Advertisment> list = new List<Advertisment>();
  15. // if (RedisDbconn.Instance.Exists(key))
  16. // {
  17. // list = RedisDbconn.Instance.GetList<Advertisment>(key);
  18. // if (list.Count > 0)
  19. // {
  20. // return list;
  21. // }
  22. // }
  23. List<Advertisment> newlist = new List<Advertisment>();
  24. WebCMSEntities db = new WebCMSEntities();
  25. var mysqllist = db.Advertisment.Where(m => m.ColId == ColId).OrderByDescending(m => m.Sort).OrderByDescending(m => m.Id).ToList();
  26. if (mysqllist.Count > 0)
  27. {
  28. foreach (var sub in mysqllist)
  29. {
  30. newlist.Add(sub);
  31. }
  32. }
  33. db.Dispose();
  34. return newlist;
  35. }
  36. #endregion
  37. }
  38. }