public ShardingQueryCompiler(IQueryContextFactory queryContextFactory, ICompiledQueryCache compiledQueryCache, ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator, IDatabase database, IDiagnosticsLogger <DbLoggerCategory.Query> logger, ICurrentDbContext currentContext, IEvaluatableExpressionFilter evaluatableExpressionFilter, IModel model) : base(queryContextFactory, compiledQueryCache, compiledQueryCacheKeyGenerator, database, logger, currentContext, evaluatableExpressionFilter, model)
 {
     _queryContextFactory = queryContextFactory;
     _database            = database;
     _logger = logger;
     _model  = model;
 }
        public CustomQueryCompiler(
            IQueryContextFactory queryContextFactory,
            ICompiledQueryCache compiledQueryCache,
            ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
            IDatabase database,
            IDiagnosticsLogger <DbLoggerCategory.Query> logger,
            ICurrentDbContext currentContext,
            IQueryModelGenerator queryModelGenerator,
            IEvaluatableExpressionFilter evaluableExpressionFilter)
            : base(queryContextFactory, compiledQueryCache, compiledQueryCacheKeyGenerator, database, logger, currentContext, queryModelGenerator)
        {
            Check.NotNull(queryContextFactory, nameof(queryContextFactory));
            Check.NotNull(compiledQueryCache, nameof(compiledQueryCache));
            Check.NotNull(compiledQueryCacheKeyGenerator, nameof(compiledQueryCacheKeyGenerator));
            Check.NotNull(database, nameof(database));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(currentContext, nameof(currentContext));
            Check.NotNull(evaluableExpressionFilter, nameof(evaluableExpressionFilter));

            _queryModelGenerator = queryModelGenerator;

            _cacheProvider = currentContext.Context.GetService <ICacheProvider>();

            _xxHash = xxHashFactory.Instance.Create(new xxHashConfig()
            {
                HashSizeInBits = 64
            });
        }
        public CustomQueryCompiler(IQueryContextFactory queryContextFactory, ICompiledQueryCache compiledQueryCache, ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator
                                   , IDatabase database, IDiagnosticsLogger <DbLoggerCategory.Query> logger, ICurrentDbContext currentContext, IQueryModelGenerator queryModelGenerator, IEvaluatableExpressionFilter evaluatableExpressionFilter)
            : base(queryContextFactory, compiledQueryCache, compiledQueryCacheKeyGenerator, database, logger, currentContext, queryModelGenerator)
        {
            Check.NotNull(queryContextFactory, nameof(queryContextFactory));
            Check.NotNull(compiledQueryCache, nameof(compiledQueryCache));
            Check.NotNull(compiledQueryCacheKeyGenerator, nameof(compiledQueryCacheKeyGenerator));
            Check.NotNull(database, nameof(database));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(currentContext, nameof(currentContext));
            Check.NotNull(evaluatableExpressionFilter, nameof(evaluatableExpressionFilter));

            _queryContextFactory            = queryContextFactory;
            _compiledQueryCache             = compiledQueryCache;
            _compiledQueryCacheKeyGenerator = compiledQueryCacheKeyGenerator;
            _database            = database;
            _logger              = logger;
            _contextType         = currentContext.Context.GetType();
            _queryModelGenerator = queryModelGenerator;

            _logFormatter = (queryKey, ex) => $"Cache hit for query [0x{queryKey}] with: {ex?.Message ?? "no error"}";

            _cacheableOptions = currentContext.Context
                                .GetService <IDbContextServices>()
                                .ContextOptions
                                .FindExtension <CacheableOptionsExtension>();

            _cacheProvider = currentContext.Context.GetService <ICacheProvider>();
        }
示例#4
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public QueryCompiler(
            [NotNull] IQueryContextFactory queryContextFactory,
            [NotNull] ICompiledQueryCache compiledQueryCache,
            [NotNull] ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
            [NotNull] IDatabase database,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Query> logger,
            [NotNull] ICurrentDbContext currentContext,
            [NotNull] IEvaluatableExpressionFilter evaluatableExpressionFilter,
            [NotNull] IModel model)
        {
            Check.NotNull(queryContextFactory, nameof(queryContextFactory));
            Check.NotNull(compiledQueryCache, nameof(compiledQueryCache));
            Check.NotNull(compiledQueryCacheKeyGenerator, nameof(compiledQueryCacheKeyGenerator));
            Check.NotNull(database, nameof(database));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(currentContext, nameof(currentContext));
            Check.NotNull(evaluatableExpressionFilter, nameof(evaluatableExpressionFilter));
            Check.NotNull(model, nameof(model));

            _queryContextFactory            = queryContextFactory;
            _compiledQueryCache             = compiledQueryCache;
            _compiledQueryCacheKeyGenerator = compiledQueryCacheKeyGenerator;
            _database    = database;
            _logger      = logger;
            _contextType = currentContext.Context.GetType();
            _evaluatableExpressionFilter = evaluatableExpressionFilter;
            _model = model;
        }
示例#5
0
        private int GetNumberOfCacheEntries(ICompiledQueryCache compiledQueryCache)
        {
            var memoryCacheField = compiledQueryCache.GetType().GetField(
                "_memoryCache",
                BindingFlags.Instance | BindingFlags.NonPublic);
            var memoryCache          = (MemoryCache)memoryCacheField.GetValue(compiledQueryCache);
            var numberOfCacheEntries = memoryCache.Count;

            return(numberOfCacheEntries);
        }
示例#6
0
 public ReplaceQueryCompiler(
     IQueryContextFactory queryContextFactory,
     ICompiledQueryCache compiledQueryCache,
     ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
     IDatabase database,
     ISensitiveDataLogger <QueryCompiler> logger,
     MethodInfoBasedNodeTypeRegistry methodInfoBasedNodeTypeRegistry,
     ICurrentDbContext currentContext) : base(queryContextFactory, compiledQueryCache, compiledQueryCacheKeyGenerator, database, logger, methodInfoBasedNodeTypeRegistry, currentContext)
 {
     methodInfoBasedNodeTypeRegistry.Register(ReplaceIncludeExpressionNode.SupportedMethods, typeof(ReplaceIncludeExpressionNode));
     methodInfoBasedNodeTypeRegistry.Register(ReplaceThenIncludeExpressionNode.SupportedMethods, typeof(ReplaceThenIncludeExpressionNode));
 }
示例#7
0
        public QueryCompiler(
            [NotNull] IQueryContextFactory contextFactory,
            [NotNull] ICompiledQueryCache cache,
            [NotNull] ICompiledQueryCacheKeyGenerator cacheKeyGenerator,
            [NotNull] IDatabase database)
        {
            Check.NotNull(contextFactory, nameof(contextFactory));
            Check.NotNull(cache, nameof(cache));
            Check.NotNull(cacheKeyGenerator, nameof(cacheKeyGenerator));
            Check.NotNull(database, nameof(database));

            _contextFactory    = contextFactory;
            _cache             = cache;
            _cacheKeyGenerator = cacheKeyGenerator;
            _database          = database;
        }
        public EntityQueryProvider(
            [NotNull] DbContext context,
            [NotNull] IDataStore dataStore,
            [NotNull] ICompiledQueryCache compiledQueryCache,
            [NotNull] IQueryContextFactory queryContextFactory)
        {
            Check.NotNull(context, nameof(context));
            Check.NotNull(dataStore, nameof(dataStore));
            Check.NotNull(compiledQueryCache, nameof(compiledQueryCache));
            Check.NotNull(queryContextFactory, nameof(queryContextFactory));

            _context             = context;
            _dataStore           = dataStore;
            _compiledQueryCache  = compiledQueryCache;
            _queryContextFactory = queryContextFactory;
        }
 public CustomQueryCompiler(IQueryContextFactory queryContextFactory,
                            ICompiledQueryCache compiledQueryCache,
                            ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
                            IDatabase database,
                            IDiagnosticsLogger <DbLoggerCategory.Query> logger,
                            ICurrentDbContext currentContext,
                            IQueryModelGenerator queryModelGenerator)
     : base(queryContextFactory,
            compiledQueryCache,
            compiledQueryCacheKeyGenerator,
            database,
            logger,
            currentContext,
            queryModelGenerator)
 {
     _logger = logger.Logger;
 }
        public InfoCarrierQueryCompiler(
            IQueryContextFactory queryContextFactory,
            ICompiledQueryCache compiledQueryCache,
            ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
            IDiagnosticsLogger <DbLoggerCategory.Query> logger,
            ICurrentDbContext currentDbContext,
            IEvaluatableExpressionFilter evaluatableExpressionFilter)
        {
            this.queryContextFactory            = queryContextFactory;
            this.compiledQueryCache             = compiledQueryCache;
            this.compiledQueryCacheKeyGenerator = compiledQueryCacheKeyGenerator;
            this.logger                      = logger;
            this.currentDbContext            = currentDbContext;
            this.evaluatableExpressionFilter = evaluatableExpressionFilter;

            this.entityTypeMap = new Lazy <IReadOnlyDictionary <string, IEntityType> >(
                () => InfoCarrierQueryResultMapper.BuildEntityTypeMap(currentDbContext.Context));
        }
示例#11
0
 public MongoQueryCompiler(
     IQueryContextFactory queryContextFactory,
     ICompiledQueryCache compiledQueryCache,
     ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
     IDatabase database,
     IDiagnosticsLogger <DbLoggerCategory.Query> logger,
     ICurrentDbContext currentContext,
     IEvaluatableExpressionFilter evaluatableExpressionFilter,
     IModel model)
     : base(queryContextFactory,
            compiledQueryCache,
            compiledQueryCacheKeyGenerator,
            database,
            logger,
            currentContext,
            evaluatableExpressionFilter,
            model)
 {
 }
示例#12
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public QueryCompiler(
     IQueryContextFactory queryContextFactory,
     ICompiledQueryCache compiledQueryCache,
     ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
     IDatabase database,
     IDiagnosticsLogger <DbLoggerCategory.Query> logger,
     ICurrentDbContext currentContext,
     IEvaluatableExpressionFilter evaluatableExpressionFilter,
     IModel model)
 {
     _queryContextFactory            = queryContextFactory;
     _compiledQueryCache             = compiledQueryCache;
     _compiledQueryCacheKeyGenerator = compiledQueryCacheKeyGenerator;
     _database    = database;
     _logger      = logger;
     _contextType = currentContext.Context.GetType();
     _evaluatableExpressionFilter = evaluatableExpressionFilter;
     _model = model;
 }
示例#13
0
        public CustomQueryCompiler(IQueryContextFactory queryContextFactory,
                                   ICompiledQueryCache compiledQueryCache,
                                   ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
                                   IDatabase database, IDiagnosticsLogger <DbLoggerCategory.Query> logger,
                                   ICurrentDbContext currentContext,
                                   IEvaluatableExpressionFilter evaluatableExpressionFilter,
                                   IModel model)
#pragma warning disable EF1001 // Internal EF Core API usage.
            : base(queryContextFactory,
                   compiledQueryCache,
                   compiledQueryCacheKeyGenerator,
                   database,
                   logger,
                   currentContext,
                   evaluatableExpressionFilter,
                   model)
#pragma warning restore EF1001 // Internal EF Core API usage.
        {
            _context = currentContext;
        }
示例#14
0
        public QueryCompiler(
            [NotNull] IQueryContextFactory queryContextFactory,
            [NotNull] ICompiledQueryCache compiledQueryCache,
            [NotNull] ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
            [NotNull] IDatabase database,
            [NotNull] ILogger <QueryCompiler> logger,
            [NotNull] DbContext context)
        {
            Check.NotNull(queryContextFactory, nameof(queryContextFactory));
            Check.NotNull(compiledQueryCache, nameof(compiledQueryCache));
            Check.NotNull(compiledQueryCacheKeyGenerator, nameof(compiledQueryCacheKeyGenerator));
            Check.NotNull(database, nameof(database));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(context, nameof(context));

            _queryContextFactory            = queryContextFactory;
            _compiledQueryCache             = compiledQueryCache;
            _compiledQueryCacheKeyGenerator = compiledQueryCacheKeyGenerator;
            _database    = database;
            _logger      = logger;
            _contextType = context.GetType();
        }
示例#15
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public QueryCompiler(
            [NotNull] IQueryContextFactory queryContextFactory,
            [NotNull] ICompiledQueryCache compiledQueryCache,
            [NotNull] ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
            [NotNull] IDatabase database,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Query> logger,
            [NotNull] ICurrentDbContext currentContext,
            [NotNull] IQueryModelGenerator queryModelGenerator)
        {
            Check.NotNull(queryContextFactory, nameof(queryContextFactory));
            Check.NotNull(compiledQueryCache, nameof(compiledQueryCache));
            Check.NotNull(compiledQueryCacheKeyGenerator, nameof(compiledQueryCacheKeyGenerator));
            Check.NotNull(database, nameof(database));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(currentContext, nameof(currentContext));

            _queryContextFactory            = queryContextFactory;
            _compiledQueryCache             = compiledQueryCache;
            _compiledQueryCacheKeyGenerator = compiledQueryCacheKeyGenerator;
            _database            = database;
            _logger              = logger;
            _contextType         = currentContext.Context.GetType();
            _queryModelGenerator = queryModelGenerator;
        }
示例#16
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public QueryCompiler(
            [NotNull] IQueryContextFactory queryContextFactory,
            [NotNull] ICompiledQueryCache compiledQueryCache,
            [NotNull] ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator,
            [NotNull] IDatabase database,
            [NotNull] ISensitiveDataLogger <QueryCompiler> logger,
            [NotNull] INodeTypeProviderFactory nodeTypeProviderFactory,
            [NotNull] ICurrentDbContext currentContext)
        {
            Check.NotNull(queryContextFactory, nameof(queryContextFactory));
            Check.NotNull(compiledQueryCache, nameof(compiledQueryCache));
            Check.NotNull(compiledQueryCacheKeyGenerator, nameof(compiledQueryCacheKeyGenerator));
            Check.NotNull(database, nameof(database));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(currentContext, nameof(currentContext));

            _queryContextFactory            = queryContextFactory;
            _compiledQueryCache             = compiledQueryCache;
            _compiledQueryCacheKeyGenerator = compiledQueryCacheKeyGenerator;
            _database = database;
            _logger   = logger;
            _nodeTypeProviderFactory = nodeTypeProviderFactory;
            _contextType             = currentContext.Context.GetType();
        }
 public TranslationQueryCompiler(IQueryContextFactory queryContextFactory, ICompiledQueryCache compiledQueryCache, ICompiledQueryCacheKeyGenerator compiledQueryCacheKeyGenerator, IDatabase database, IInterceptingLogger <LoggerCategory.Query> logger, INodeTypeProviderFactory nodeTypeProviderFactory, ICurrentDbContext currentContext) : base(queryContextFactory, compiledQueryCache, compiledQueryCacheKeyGenerator, database, logger, nodeTypeProviderFactory, currentContext)
 {
 }