public bool Exists(Info info) { if (info == null) return false; ModelIdHelper.GenerateId<Info>(info); return Read() .Exists(item => item != null && item.Id == info.Id); }
public Info Delete(Info info) { if (info == null) return info; ModelIdHelper.GenerateId<Info>(info); Info rs = Provider.Delete<Info>(info); Build(); CacheKey.ReBuildCache(); return rs; }
public Info Update(Info info) { if (info == null) return info; ModelIdHelper.GenerateId<Info>(info); if (!Exists(info)) { throw new Exception(string.Format("更新列表‘{0}’对象时,发现对象不存在", typeof(Info).Name)); } Info rs = Provider.Update<Info>(info); Build(); CacheKey.ReBuildCache(); return rs; }
public List<Info> Read() { if (Cache.Get<List<Info>>(CacheKey) == null) { List<Info> infoList = Provider.Read<Info>(); foreach (Info info in infoList) { ModelIdHelper.GenerateId<Info>(info); } Cache.Add(CacheKey, infoList); } return Cache.Get<List<Info>>(CacheKey); }