コード例 #1
0
        /// <summary>
        ///     Load all campaignOwners from the database.
        /// </summary>
        /// <returns></returns>
        private CampaignOwnerSet LoadCampaignOwnerSet()
        {
            var campaignOwnerOwnerSet = new CampaignOwnerSet();

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

            IQueryable <CampaignOwnerEntity> campaignOwners = from c in metaData.CampaignOwner select c;

            var campaignOwnerCollection = ((ILLBLGenProQuery)campaignOwners).Execute <CampaignOwnerCollection>();

            // Fill the entity set from the data collection
            if (campaignOwnerCollection.Count > 0)
            {
                foreach (var campaignOwnerEntity in campaignOwnerCollection)
                {
                    var campaignOwner = new CampaignOwner(campaignOwnerEntity);

                    campaignOwnerOwnerSet.Add(campaignOwner);
                }
            }

            // Return the entity set
            return(campaignOwnerOwnerSet);
        }
コード例 #2
0
        /// <summary>
        ///     Get the collection of all campaignOwners.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of campaignOwners</returns>
        public CampaignOwnerSet GetCampaignOwners(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadCampaignOwnerSet());
            }

            CampaignOwnerSet campaignOwnerOwnerSet;

            string cacheKey = CampaignOwnerSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <CampaignOwnerSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                campaignOwnerOwnerSet = LoadCampaignOwnerSet();

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

            return(campaignOwnerOwnerSet);
        }