public CachedQueryRepository(QueryRepository <TEntity> queryRepository, IMemoryCache cache, IConfiguration config)
        {
            var cacheSection = config.GetSection("EfCore:Cache");

            _queryRepository = queryRepository;
            _cache           = cache;
            _cacheOptions    = new MemoryCacheEntryOptions().SetAbsoluteExpiration(relative: TimeSpan.FromSeconds(cacheSection.GetValue("ExpiredTime", 60)));
        }
        public IQueryRepository <TEntity> QueryRepository <TEntity>() where TEntity : class, IAggregateRoot
        {
            if (_repositories == null)
            {
                _repositories = new ConcurrentDictionary <Type, object>();
            }

            if (!_repositories.ContainsKey(typeof(TEntity)))
            {
                //var memoryCache = scope.ServiceProvider.GetService<IMemoryCache>();
                //var config = scope.ServiceProvider.GetService<IConfiguration>();
                //var cachedRepo = new CachedQueryRepository<TEntity>(new QueryRepository<TEntity>(_context), memoryCache, config);
                var cachedRepo = new QueryRepository <TEntity>(_context);
                _repositories[typeof(TEntity)] = cachedRepo;
            }

            return((IQueryRepository <TEntity>)_repositories[typeof(TEntity)]);
        }