Esempio n. 1
0
        public List <Country> LoadAllOrderedByName()
        {
            string cacheKey = _cacheHandler.GetCacheKey(cacheKeyPrefix, "AllOrderedByName");

            if (TryGetAllOrderedByNameFromCache(cacheKey, out var countries))
            {
                return(countries);
            }
            var loadLock = _countriesCacheInfo.CacheLocks.GetOrAdd(_cacheHandler.GetCacheKey(cacheKeyPrefix, "AllOrderedByName", "Load"), new object());

            lock (loadLock)
            {
                //Was it added to the cache while wating for lock release?
                if (TryGetAllOrderedByNameFromCache(cacheKey, out countries))
                {
                    return(countries);
                }
                var queryParams = new BaseQueryParams
                {
                    PageIndex      = 0,
                    PageSize       = 10000,
                    OrderByColumns = new List <OrderByColumn> {
                        new OrderByColumn {
                            ColumnName = "Name"
                        }
                    }
                };
                countries = base.GetAll(queryParams);
                if (countries != null)
                {
                    _countriesCacheInfo.AddToCache(countries, cacheKey);
                }
                return(countries);
            }
        }