예제 #1
0
        /// <summary>
        /// Gets all the AppSettings items from the cache or the database.
        /// </summary>
        ///
        /// <param name="userContext">
        /// User context.
        /// </param>
        ///
        /// <returns>
        /// Collection of all the AppSettings items.
        /// </returns>
        private static TCollection <AppSettings> GetAppSettingsCollection(IUserContext userContext)
        {
            const string cacheKey = "AppSettingsBusiness.GetAppSettingsCollection";

            var collection = CacheServiceHelper.Current.Get <TCollection <AppSettings> >(cacheKey);

            if (collection == null)
            {
                lock (_locker)
                {
                    if (collection == null)
                    {
                        using (var et = new ExecutionTracerService())
                            using (var db = new AppSettingsCrud(userContext))
                            {
                                var options = new SearchOptions();

                                collection = db.Search(ref options);
                            }

                        CacheServiceHelper.Current.Add(new CacheItem
                        {
                            Key        = cacheKey,
                            Data       = collection,
                            Expiration = DateTime.Now.AddMinutes(CACHE_DELAY_IN_MINS)
                        });
                    }
                }
            }

            return(collection);
        }
 /// <summary>
 /// Gets entities with search options.
 /// </summary>
 ///
 /// <param name="userContext">
 /// User context.
 /// </param>
 ///
 /// <param name="options">
 /// Optional options, filters, orderby, paging, etc.
 /// </param>
 ///
 /// <returns>
 /// A collection of entities.
 /// </returns>
 public TCollection <VahapYigit.Test.Models.AppSettings> Search(IUserContext userContext, ref SearchOptions options)
 {
     using (var et = new ExecutionTracerService())
         using (var db = new AppSettingsCrud(userContext))
         {
             return(db.Search(ref options));
         }
 }