12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using CP.Cache;
- using CP.Model;
- using CP.Model.other;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CP.Business
- {
- public class TermBLL : DataConnect
- {
- /// 缓存
- /// </summary>
- static WMCache cache = WMCache.GetCacheService();
- public List<Term> GetList()
- {
- string key = string.Format(CacheKeys.TermList);
- var list = cache.GetObject<List<Term>>(key);
- if (list == null)
- {
- DataConnect dc = new DataConnect();
- list= dc.db.Fetch<Term>($" ORDER BY id asc");
- cache.AddObject(CacheKeys.TermList, list, (int)CacheTime.System);
- }
- return list;
- }
- /// <summary>
- /// 获取单个实体类
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public Term GetTerm(int id) {
- string key = string.Format(CacheKeys.TermList);
- var list = cache.GetObject<List<Term>>(key);
- if (list == null)
- {
- DataConnect dc = new DataConnect();
- list = dc.db.Fetch<Term>($" ORDER BY id asc");
- cache.AddObject(CacheKeys.TermList, list, (int)CacheTime.System);
- }
- return list.Where(p=>p.id==id).ToList()[0];
-
- }
- }
- }
|