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