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