コード例 #1
0
        public Task <PropertyDictionaryItem[]> GetByIdsAsync(string[] ids)
        {
            var cacheKey = CacheKey.With(GetType(), "GetByIdsAsync", string.Join(",", ids));

            return(_platformMemoryCache.GetOrCreateExclusive(cacheKey, async(cacheEntry) =>
            {
                cacheEntry.AddExpirationToken(DictionaryItemsCacheRegion.CreateChangeToken());
                PropertyDictionaryItem[] result;

                using (var repository = _repositoryFactory())
                {
                    //Optimize performance and CPU usage
                    repository.DisableChangesTracking();

                    result = (await repository.GetPropertyDictionaryItemsByIdsAsync(ids))
                             .Select(x => x.ToModel(AbstractTypeFactory <PropertyDictionaryItem> .TryCreateInstance()))
                             .ToArray();
                }
                return result;
            }));
        }