Example #1
0
        /// <summary>
        ///     Get the collection of all channel stores. The cache is enabled by default.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns></returns>
        public ChannelStoreSet GetChannelStores(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadChannelStoreSet());
            }

            ChannelStoreSet channelStoreSet;

            var cacheKey = ChannelStoreSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelStoreSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                channelStoreSet = LoadChannelStoreSet();

                if (channelStoreSet != null)
                {
                    // Add the entity set to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, channelStoreSet,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              channelStoreSet.GetType()));
                }
            }
            else
            {
                channelStoreSet = CacheManagerProvider.GetCacheManagerInstance().Get <ChannelStoreSet>(cacheKey);
            }
            return(channelStoreSet);
        }
Example #2
0
        /// <summary>
        ///     Load all channel stores from the database.
        /// </summary>
        /// <returns></returns>
        private ChannelStoreSet LoadChannelStoreSet()
        {
            var channelStoreSet = new ChannelStoreSet();

            // Get the collection from the ORM data layer
            var metaData = new LinqMetaData();
            IQueryable <ChannelStoreEntity> channelStores = from c in metaData.ChannelStore select c;

            var channelStoreCollection = ((ILLBLGenProQuery)channelStores).Execute <ChannelStoreCollection>();

            if (channelStoreCollection.Count > 0)
            {
                foreach (var channelStoreEntity in channelStoreCollection)
                {
                    var channelStore = new ChannelStore(channelStoreEntity);
                    channelStoreSet.Add(channelStore);
                }
            }
            return(channelStoreSet);
        }