Exemple #1
0
        /// <summary>
        ///     Get the collection of all channelCustomers.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of channelCustomers</returns>
        public ChannelCustomerSet GetChannelCustomers(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadChannelCustomerSet());
            }

            ChannelCustomerSet channelCustomerSet;

            string cacheKey = ChannelCustomerSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelCustomerSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                channelCustomerSet = LoadChannelCustomerSet();

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

            return(channelCustomerSet);
        }
Exemple #2
0
        /// <summary>
        ///     Load a channelCustomer from the database given its Id.
        /// </summary>
        /// <param name="channelId">The channelCustomer identifier</param>
        /// <returns></returns>
        public ChannelCustomerSet LoadChannelCustomerByChannelId(int channelId)
        {
            var metaData           = new LinqMetaData();
            var channelCustomer    = metaData.ChannelCustomer.Where(e => e.ChannelId == channelId);
            var customerCollection = ((ILLBLGenProQuery)channelCustomer).Execute <ChannelCustomerCollection>();

            var channelCustomerSet = new ChannelCustomerSet();

            // Fill the entity set from the data collection
            if (customerCollection.Count > 0)
            {
                foreach (var customerEntity in customerCollection)
                {
                    var customer = new ChannelCustomer(customerEntity);

                    channelCustomerSet.Add(customer);
                }
            }
            // Return the entity set
            return(channelCustomerSet);
        }
Exemple #3
0
        /// <summary>
        ///     Load all channelCustomers from the database.
        /// </summary>
        /// <returns></returns>
        private ChannelCustomerSet LoadChannelCustomerSet()
        {
            var channelCustomerSet = new ChannelCustomerSet();

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

            IQueryable <ChannelCustomerEntity> channelCustomers = from c in metaData.ChannelCustomer select c;

            var channelCustomerCollection = ((ILLBLGenProQuery)channelCustomers).Execute <ChannelCustomerCollection>();

            // Fill the entity set from the data collection
            if (channelCustomerCollection.Count > 0)
            {
                foreach (var channelCustomerEntity in channelCustomerCollection)
                {
                    var channelCustomer = new ChannelCustomer(channelCustomerEntity);
                    channelCustomerSet.Add(channelCustomer);
                }
            }

            // Return the entity set
            return(channelCustomerSet);
        }