Пример #1
0
        /// <summary>
        ///     Load all channel items from the database.
        /// </summary>
        /// <returns></returns>
        private ChannelItemSet LoadChannelItemSet()
        {
            var channelItemSet = new ChannelItemSet();

            // Get the collection from the ORM data layer
            var metaData = new LinqMetaData();

            IQueryable <ChannelItemEntity> channelItems = from c in metaData.ChannelItem select c;

            var channelItemCollection = ((ILLBLGenProQuery)channelItems).Execute <ChannelItemCollection>();

            // Fill the entity set from the data collection
            if (channelItemCollection.Count > 0)
            {
                foreach (var channelItemEntity in channelItemCollection)
                {
                    var channelItem = new ChannelItem(channelItemEntity);

                    channelItemSet.Add(channelItem);
                }
            }

            // Return the entity set
            return(channelItemSet);
        }
Пример #2
0
        /// <summary>
        ///     Get the collection of all channel items.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of channel items</returns>
        public ChannelItemSet GetChannelItems(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadChannelItemSet());
            }

            ChannelItemSet channelItemSet;

            string cacheKey = ChannelItemSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelItemSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                channelItemSet = LoadChannelItemSet();

                if (channelItemSet != null)
                {
                    // Add the entity set to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, channelItemSet,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              channelItemSet.GetType()));
                }
            }
            else
            {
                channelItemSet = CacheManagerProvider.GetCacheManagerInstance().Get <ChannelItemSet>(cacheKey);
            }

            return(channelItemSet);
        }