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>();
        }
        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 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;
 }
示例#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
 public QueryEventBus(QueryQueue queryQueue,
                      IQueryContextFactory queryContextFactory,
                      IQueuePriorityRule queuePriorityRule,
                      ILogger <QueryEventBus> logger)
 {
     _queryQueue          = queryQueue;
     _queryContextFactory = queryContextFactory;
     _logger            = logger;
     _queryEnqueueLock  = new SemaphoreSlim(1);
     _queuePriorityRule = queuePriorityRule;
 }
示例#6
0
        public QueryKeyGenerator(IQueryContextFactory queryContextFactory, IQueryCompiler queryCompiler, IDiagnosticsLogger <DbLoggerCategory.Query> logger)
        {
            if (queryCompiler is not QueryCompiler compiler)
            {
                throw new InvalidCastException($"Implementation type of '{nameof(IQueryCompiler)}' must be '{typeof(QueryCompiler)}'");
            }

            _queryCompiler       = compiler;
            _queryContextFactory = queryContextFactory;
            _logger = logger;
        }
示例#7
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));
 }
示例#8
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;
        }
示例#10
0
        public QueryProcessor(
            IHandlerConfiguration handlerConfiguration,
            IQueryContextFactory queryContextFactory,
            IReadOnlyDictionary <string, object> contextBagData = null)
        {
            if (handlerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(handlerConfiguration));
            }

            _handlerRegistry  = handlerConfiguration.HandlerRegistry ?? throw new ArgumentException($"{nameof(handlerConfiguration.HandlerRegistry)} must not be null", nameof(handlerConfiguration));
            _handlerFactory   = handlerConfiguration.HandlerFactory ?? throw new ArgumentException($"{nameof(handlerConfiguration.HandlerFactory)} must not be null", nameof(handlerConfiguration));
            _decoratorFactory = handlerConfiguration.DecoratorFactory ?? throw new ArgumentException($"{nameof(handlerConfiguration.DecoratorFactory)} must not be null", nameof(handlerConfiguration));

            _queryContextFactory = queryContextFactory ?? throw new ArgumentNullException(nameof(queryContextFactory));
            _contextBagData      = contextBagData ?? new Dictionary <string, object>();
        }
示例#11
0
 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));
        }
示例#13
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;
 }
示例#14
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)
 {
 }
示例#15
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;
        }
示例#16
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();
        }
示例#17
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;
        }
示例#18
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();
        }
示例#19
0
 /// <summary>
 /// Creates the context <see cref="IQueryContext"/> for the query.
 /// </summary>
 /// <param name="contextFactory">Factory to generate the context</param>
 /// <returns>The <see cref="IQueryContext"/></returns>
 /// <remarks>Uses the visitor pattern generating the context.</remarks>
 public abstract IQueryContext CreateContext(IQueryContextFactory contextFactory);
示例#20
0
 public override IQueryContext CreateContext(IQueryContextFactory contextFactory)
 {
     return(contextFactory.GenerateSingleQuoteContext(this));
 }
 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)
 {
 }
示例#22
0
 public override IQueryContext CreateContext(IQueryContextFactory contextFactory)
 {
     throw new System.NotImplementedException();
 }
示例#23
0
 public override IQueryContext CreateContext(IQueryContextFactory contextFactory)
 {
     return(_mockQueryContext.Object);
 }
示例#24
0
 public IBuildTheQueryProcessor InMemoryQueryContextFactory()
 {
     _queryContextFactory = new InMemoryQueryContextFactory();
     return(this);
 }
示例#25
0
 public IBuildTheQueryProcessor QueryContextFactory(IQueryContextFactory queryContextFactory)
 {
     _queryContextFactory = queryContextFactory ?? throw new ArgumentNullException(nameof(queryContextFactory));
     return(this);
 }
 public QuerySubscriptionCountRule(IQueryContextFactory contextFactory, QuerySubscriptions querySubscriptions, ILogger <QuerySubscriptionCountRule> logger)
 {
     _contextFactory     = contextFactory;
     _querySubscriptions = querySubscriptions;
     _logger             = logger;
 }