Beispiel #1
0
        /// <summary>
        /// Tries to get any item by item first from the cache and then from the database
        /// </summary>
        public async Task <T> GetAny(string propertyName, string propertyValue)
        {
            var cacheResult = _cache.GetBy(propertyName, propertyValue);

            if (!cacheResult.Any())
            {
                var queryResult = await GetByFilter(propertyName, propertyValue);

                if (queryResult.Any())
                {
                    return(queryResult.First());
                }
                else
                {
                    return(null);
                }
            }

            return(cacheResult.First());
        }