/// <summary> /// Get the collection of all redemptionCodes. /// </summary> /// <param name="noCache">Bypass the cache</param> /// <param name="refreshCache">Force refresh the cache</param> /// <returns>A set of redemptionCodes</returns> public RedemptionCodeSet GetRedemptionCodes(bool noCache, bool refreshCache) { // If no cache the load and return a entity set from the database if (noCache && !refreshCache) { return(LoadRedemptionCodeSet()); } RedemptionCodeSet redemptionCodeSet; string cacheKey = RedemptionCodeSet.StaticGetCacheKey(); if (!CacheManagerProvider.GetCacheManagerInstance().Contains <RedemptionCodeSet>(cacheKey) || refreshCache) { // Load the entity set from the database redemptionCodeSet = LoadRedemptionCodeSet(); if (redemptionCodeSet != null) { // Add the entity set to the cache by reading caching parameters from the configuration CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, redemptionCodeSet, ConfigurationManager.GetCacheExpirationByType( redemptionCodeSet.GetType())); } } else { redemptionCodeSet = CacheManagerProvider.GetCacheManagerInstance().Get <RedemptionCodeSet>(cacheKey); } return(redemptionCodeSet); }
/// <summary> /// Load all redemptionCodes from the database. /// </summary> /// <returns></returns> private RedemptionCodeSet LoadRedemptionCodeSet() { var redemptionCodeSet = new RedemptionCodeSet(); // Get the collection from the ORM data layer var metaData = new LinqMetaData(); IQueryable <RedemptionCodeEntity> redemptionCodes = from c in metaData.RedemptionCode select c; var redemptionCodeCollection = ((ILLBLGenProQuery)redemptionCodes).Execute <RedemptionCodeCollection>(); // Fill the entity set from the data collection if (redemptionCodeCollection.Count > 0) { redemptionCodeSet.AddRange(redemptionCodeCollection.Select(entity => new RedemptionCode(entity))); } // Return the entity set return(redemptionCodeSet); }