private static IServiceCollection AddQuery(this IServiceCollection serviceCollection) => serviceCollection .AddMemoryCache() .AddSingleton(_ => MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly()) .AddScoped <ICompiledQueryCache, CompiledQueryCache>() .AddScoped <IAsyncQueryProvider, EntityQueryProvider>() .AddScoped <IQueryCompiler, QueryCompiler>() .AddScoped <IQueryAnnotationExtractor, QueryAnnotationExtractor>() .AddScoped <IQueryOptimizer, QueryOptimizer>() .AddScoped <IEntityTrackingInfoFactory, EntityTrackingInfoFactory>() .AddScoped <ISubQueryMemberPushDownExpressionVisitor, SubQueryMemberPushDownExpressionVisitor>() .AddScoped <ITaskBlockingExpressionVisitor, TaskBlockingExpressionVisitor>() .AddScoped <IEntityResultFindingExpressionVisitorFactory, EntityResultFindingExpressionVisitorFactory>() .AddScoped <IMemberAccessBindingExpressionVisitorFactory, MemberAccessBindingExpressionVisitorFactory>() .AddScoped <INavigationRewritingExpressionVisitorFactory, NavigationRewritingExpressionVisitorFactory>() .AddScoped <IOrderingExpressionVisitorFactory, OrderingExpressionVisitorFactory>() .AddScoped <IQuerySourceTracingExpressionVisitorFactory, QuerySourceTracingExpressionVisitorFactory>() .AddScoped <IRequiresMaterializationExpressionVisitorFactory, RequiresMaterializationExpressionVisitorFactory>() .AddScoped <CompiledQueryCacheKeyGenerator>() .AddScoped <ExpressionPrinter>() .AddScoped <ResultOperatorHandler>() .AddScoped <QueryCompilationContextFactory>() .AddScoped <ProjectionExpressionVisitorFactory>() .AddScoped(p => GetProviderServices(p).QueryContextFactory) .AddScoped(p => GetProviderServices(p).QueryCompilationContextFactory) .AddScoped(p => GetProviderServices(p).CompiledQueryCacheKeyGenerator) .AddScoped(p => GetProviderServices(p).EntityQueryModelVisitorFactory) .AddScoped(p => GetProviderServices(p).EntityQueryableExpressionVisitorFactory) .AddScoped(p => GetProviderServices(p).ExpressionPrinter) .AddScoped(p => GetProviderServices(p).ResultOperatorHandler) .AddScoped(p => GetProviderServices(p).ProjectionExpressionVisitorFactory);
/// <summary> /// Creates a default <see cref="CompoundNodeTypeProvider"/> that already has all expression node parser defined by the re-linq assembly /// registered. Users can add inner providers to register their own expression node parsers. /// </summary> /// <returns>A default <see cref="CompoundNodeTypeProvider"/> that already has all expression node parser defined by the re-linq assembly /// registered.</returns> public static CompoundNodeTypeProvider CreateDefaultNodeTypeProvider() { var innerProviders = new INodeTypeProvider[] { MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly(), MethodNameBasedNodeTypeRegistry.CreateFromRelinqAssembly() }; return(new CompoundNodeTypeProvider(innerProviders)); }
private static IQueryParser CreateQueryParser() { var nodeTypeProvider = new CompoundNodeTypeProvider(new INodeTypeProvider[] { MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly() }); var transformerRegistry = ExpressionTransformerRegistry.CreateDefault(); var expressionTreeParser = new ExpressionTreeParser(nodeTypeProvider, ExpressionTreeParser.CreateDefaultProcessor(transformerRegistry)); return(new QueryParser(expressionTreeParser)); }
public MartenQueryParser() { var transformerRegistry = ExpressionTransformerRegistry.CreateDefault(); var processor = ExpressionTreeParser.CreateDefaultProcessor(transformerRegistry); var expressionTreeParser = new ExpressionTreeParser(MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly(), processor); _parser = new QueryParser(expressionTreeParser); }
/// <summary> /// Creates the node type provider. /// </summary> private static INodeTypeProvider CreateNodeTypeProvider() { var methodInfoRegistry = MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly(); methodInfoRegistry.Register(RemoveAllExpressionNode.GetSupportedMethods(), typeof(RemoveAllExpressionNode)); return(new CompoundNodeTypeProvider(new INodeTypeProvider[] { methodInfoRegistry, MethodNameBasedNodeTypeRegistry.CreateFromRelinqAssembly() })); }
public MartenQueryParser(Action <MethodInfoBasedNodeTypeRegistry> registerNodeTypes = null) { var transformerRegistry = ExpressionTransformerRegistry.CreateDefault(); var processor = ExpressionTreeParser.CreateDefaultProcessor(transformerRegistry); var nodeTypeRegistry = MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly(); registerNodeTypes?.Invoke(nodeTypeRegistry); var expressionTreeParser = new ExpressionTreeParser(nodeTypeRegistry, processor); _parser = new QueryParser(expressionTreeParser); }
private static ReadonlyNodeTypeProvider CreateNodeTypeProvider() { var methodInfoBasedNodeTypeRegistry = MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly(); methodInfoBasedNodeTypeRegistry .Register(QueryAnnotationExpressionNode.SupportedMethods, typeof(QueryAnnotationExpressionNode)); methodInfoBasedNodeTypeRegistry .Register(IncludeExpressionNode.SupportedMethods, typeof(IncludeExpressionNode)); methodInfoBasedNodeTypeRegistry .Register(ThenIncludeExpressionNode.SupportedMethods, typeof(ThenIncludeExpressionNode)); var innerProviders = new INodeTypeProvider[] { methodInfoBasedNodeTypeRegistry, MethodNameBasedNodeTypeRegistry.CreateFromRelinqAssembly() }; return(new ReadonlyNodeTypeProvider(new CompoundNodeTypeProvider(innerProviders))); }
/// <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 DefaultMethodInfoBasedNodeTypeRegistryFactory() : base(MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly()) { }
public void SetUp() { _methodInfoBasedNodeTypeRegistry = MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly(); }