public TEntity Delete(TEntity entity) { var key = EntityKeyInfo.GetPrimaryKey(entity); cacheManager.Remove(key, Region); return(entity); }
/// <summary> /// /// </summary> /// <param name="entity"></param> public TEntity Add(TEntity entity) { var key = EntityKeyInfo.GetPrimaryKey(entity); cacheManager.Add(key, entity, Region); return(entity); }
public TEntity Update(TEntity entity) { var key = EntityKeyInfo.GetPrimaryKey(entity); return(cacheManager.AddOrUpdate(key, Region, entity, (oldValue) => { return entity; })); }
public IEnumerable <TEntity> AddRange(IEnumerable <TEntity> entitiesToAdd) { foreach (var entity in entitiesToAdd) { var key = EntityKeyInfo.GetPrimaryKey(entity); cacheManager.Add(key, entity, Region); } return(entitiesToAdd); }
/// <summary> /// /// </summary> /// <param name="dataList"></param> /// <param name="periodTime"></param> /// <param name="isReplace"></param> /// <returns></returns> protected bool InitCache(List <TEntity> dataList, bool isReplace) { Collection.Clear(); foreach (var data in dataList) { Collection.Add(EntityKeyInfo.GetPrimaryKey(data), data); } return(true); }