Exemple #1
0
        public virtual Func <QueryContext, TResult> CreateQueryExecutor <TResult>(Expression query)
        {
            query = _queryOptimizerFactory.Create(this).Visit(query);
            // Convert EntityQueryable to ShapedQueryExpression
            query = _entityQueryableTranslatorFactory.Create(this).Visit(query);
            query = _queryableMethodTranslatingExpressionVisitorFactory.Create(Model).Visit(query);
            query = _shapedQueryOptimizerFactory.Create(this).Visit(query);

            // Inject actual entity materializer
            // Inject tracking
            query = _shapedQueryCompilingExpressionVisitorFactory.Create(this).Visit(query);

            var queryExecutorExpression = Expression.Lambda <Func <QueryContext, TResult> >(
                query,
                QueryContextParameter);

            try
            {
                return(queryExecutorExpression.Compile());
            }
            finally
            {
                Logger.QueryExecutionPlanned(new ExpressionPrinter(), queryExecutorExpression);
            }
        }
Exemple #2
0
        public virtual Func <QueryContext, TResult> CreateQueryExecutor <TResult>([NotNull] Expression query)
        {
            Check.NotNull(query, nameof(query));

            query = _queryTranslationPreprocessorFactory.Create(this).Process(query);
            // Convert EntityQueryable to ShapedQueryExpression
            query = _queryableMethodTranslatingExpressionVisitorFactory.Create(Model).Visit(query);
            query = _queryTranslationPostprocessorFactory.Create(this).Process(query);

            // Inject actual entity materializer
            // Inject tracking
            query = _shapedQueryCompilingExpressionVisitorFactory.Create(this).Visit(query);

            // If any additional parameters were added during the compilation phase (e.g. entity equality ID expression),
            // wrap the query with code adding those parameters to the query context
            query = InsertRuntimeParameters(query);

            var queryExecutorExpression = Expression.Lambda <Func <QueryContext, TResult> >(
                query,
                QueryContextParameter);

            try
            {
                return(queryExecutorExpression.Compile());
            }
            finally
            {
                Logger.QueryExecutionPlanned(new ExpressionPrinter(), queryExecutorExpression);
            }
        }
        public virtual Func <QueryContext, TResult> CreateQueryExecutor <TResult>(Expression query)
        {
            query = _queryOptimizerFactory.Create(this).Visit(query);
            // Convert EntityQueryable to ShapedQueryExpression
            query = _entityQueryableTranslatorFactory.Create(this).Visit(query);
            query = _queryableMethodTranslatingExpressionVisitorFactory.Create(Model).Visit(query);
            query = _shapedQueryOptimizerFactory.Create(this).Visit(query);

            // Inject actual entity materializer
            // Inject tracking
            query = _shapedQueryCompilingExpressionVisitorFactory.Create(this).Visit(query);

            return(Expression.Lambda <Func <QueryContext, TResult> >(
                       query,
                       QueryContextParameter)
                   .Compile());
        }