public T Get(int id) { lock (repositoryLocker) { if (_cachedDictionary.ContainsKey(id)) { return(_cachedDictionary[id]); } Dictionary <string, string> item = null; if (_loadingMode == RepositoryMode.Lazy) { item = _repositoryProvider.Get(id.ToString()); } if (item == null) { throw new InvalidOperationException("id error"); } var entity = _converter.ToEntity(item); _cachedDictionary.Add(entity.getId(), entity); return(_cachedDictionary[id]); } }
private T _Get(int id) { CheckInitialization(); if (_entityCache.ContainsKey(id)) { return(_entityCache[id]); } // it won't exist only if it was set to lazy init, otherwise cache should update with any operation if (_initType == InitType.Lazy) { // try to get that entry Dictionary <string, string> entry = _repositoryProvider.Get(id); if (entry != null) { // add that entity to the cache T entity = (T)_entityTranslator.ParseEntity(entry); _entityCache.Add(entity.Id, entity); return(entity); } } return(null); }
public async Task<ServiceResponse> Get(int idProvider) { var sr = new ServiceResponse(); try { sr.Data = _mapper.Map<ProductDto>(await _repositoryProvider.Get(idProvider)); } catch (Exception ex) { sr.AddError(ex); } return sr; }
public Models.Repository Get(Models.Repository dummy) { var cacheKey = GetCacheKey(dummy); var o = (Repository)dummy.ObjectCache().Get(cacheKey); if (o == null) { o = inner.Get(dummy); if (o == null) { return(o); } dummy.ObjectCache().Add(cacheKey, o, Kooboo.CMS.Caching.ObjectCacheExtensions.DefaultCacheItemPolicy); } return(o); }
public Models.Repository Get(Models.Repository dummy) { var cacheKey = GetCacheKey(dummy); var o = (Repository)dummy.ObjectCache().Get(cacheKey); if (o == null) { o = inner.Get(dummy); if (o == null) { return(o); } dummy.ObjectCache().Add(cacheKey, o, CacheProviderFactory.DefaultCacheItemPolicy); } return(o); }
/// <summary> /// 通过一组主键值返回一个实体对象。 /// </summary> /// <param name="primaryValues">一组主键值。</param> /// <returns></returns> public TEntity Get(params PropertyValue[] primaryValues) { return(repositoryProxy.Get(primaryValues)); }
public Repository Get(Repository dummy) { return(inner.Get(dummy)); }
/// <summary> /// 通过一组主键值返回一个实体对象。 /// </summary> /// <param name="primaryValues">一组主键值。</param> /// <returns></returns> public TEntity Get(params object[] primaryValues) { return(repositoryProxy.Get(primaryValues)); }