コード例 #1
0
 static Transformer()
 {
     __registry = new ExpressionTransformerRegistry();
     __registry.Register(new NullableTransformer());
     __registry.Register(new FirstLastNormalizingTransformer());
     __registry.Register(new SelectSelectCombiningTransformer());
     __registry.Register(new ConstantOnRightTransformer());
     __registry.Register(new CollectionConstructorTransformer());
     __registry.Register(new VBStringIndexComparisonTransformer());
     __registry.Register(new VBCompareStringTransformer());
     __registry.Register(new VBNothingConversionRemovalTransformer());
     __registry.Register(new VBCoalesceTransformer());
     __registry.Register(new VBInformationIsNothingTransformer());
 }
コード例 #2
0
 static Transformer()
 {
     __registry = new ExpressionTransformerRegistry();
     __registry.Register(new NullableTransformer());
     __registry.Register(new FirstLastNormalizingTransformer());
     __registry.Register(new SelectSelectCombiningTransformer());
     __registry.Register(new ConstantOnRightTransformer());
     __registry.Register(new CollectionConstructorTransformer());
     __registry.Register(new VBStringIndexComparisonTransformer());
     __registry.Register(new VBCompareStringTransformer());
     __registry.Register(new VBNothingConversionRemovalTransformer());
     __registry.Register(new VBCoalesceTransformer());
     __registry.Register(new VBInformationIsNothingTransformer());
 }
コード例 #3
0
        protected virtual void VisitGroupResultOperator(GroupResultOperator groupResultOperator, QueryModel queryModel)
        {
            _groupingExpressionTransformerRegistry = new ExpressionTransformerRegistry();

            // Add GROUP BY clause for the grouping key
            // And add transformations for any references to the key

            if (groupResultOperator.KeySelector.NodeType == ExpressionType.New)
            {
                // Grouping by a multipart key, so add each key to the GROUP BY clause

                var newExpression = (NewExpression)groupResultOperator.KeySelector;

                foreach (var argument in newExpression.Arguments)
                {
                    _queryPartsAggregator.AddGroupByPart(GetN1QlExpression(argument));
                }

                // Use MultiKeyExpressionTransformer to remap access to the Key property

                _groupingExpressionTransformerRegistry.Register(
                    new MultiKeyExpressionTransfomer(_queryGenerationContext.GroupingQuerySource, newExpression));
            }
            else
            {
                // Grouping by a single column

                _queryPartsAggregator.AddGroupByPart(GetN1QlExpression(groupResultOperator.KeySelector));

                // Use KeyExpressionTransformer to remap access to the Key property

                _groupingExpressionTransformerRegistry.Register(
                    new KeyExpressionTransfomer(_queryGenerationContext.GroupingQuerySource, groupResultOperator.KeySelector));
            }

            // Add transformations for any references to the element selector

            if (groupResultOperator.ElementSelector.NodeType == QuerySourceReferenceExpression.ExpressionType)
            {
                _queryGenerationContext.ExtentNameProvider.LinkExtents(
                    ((QuerySourceReferenceExpression)groupResultOperator.ElementSelector).ReferencedQuerySource,
                    _queryGenerationContext.GroupingQuerySource.ReferencedQuerySource);
            }
            else
            {
                throw new NotSupportedException("Unsupported GroupResultOperator ElementSelector Type");
            }
        }
コード例 #4
0
        static NhRelinqQueryParser()
        {
            var preTransformerRegistry = new ExpressionTransformerRegistry();

            // NH-3247: must remove .Net compiler char to int conversion before
            // parameterization occurs.
            preTransformerRegistry.Register(new RemoveCharToIntConversion());
            PreProcessor = new TransformingExpressionTreeProcessor(preTransformerRegistry);

            var transformerRegistry = ExpressionTransformerRegistry.CreateDefault();

            transformerRegistry.Register(new RemoveRedundantCast());
            transformerRegistry.Register(new SimplifyCompareTransformer());

            // If needing a compound processor for adding other processing, do not use
            // ExpressionTreeParser.CreateDefaultProcessor(transformerRegistry), it would
            // cause NH-3961 again by including a PartialEvaluatingExpressionTreeProcessor.
            // Directly instantiate a CompoundExpressionTreeProcessor instead.
            var processor = new TransformingExpressionTreeProcessor(transformerRegistry);

            var nodeTypeProvider = new NHibernateNodeTypeProvider();

            var expressionTreeParser = new ExpressionTreeParser(nodeTypeProvider, processor);

            QueryParser = new QueryParser(expressionTreeParser);
        }
コード例 #5
0
        static DateTimeTransformationRegistry()
        {
            var registry = new ExpressionTransformerRegistry();
            registry.Register(new DateTimeComparisonExpressionTransformer());

            Default = registry;
        }
コード例 #6
0
        static DateTimeTransformationRegistry()
        {
            var registry = new ExpressionTransformerRegistry();

            registry.Register(new DateTimeComparisonExpressionTransformer());

            Default = registry;
        }
コード例 #7
0
        /// <summary>
        /// Creates an <c cref="IExpressionTreeProcessor"/> that will execute
        /// <c cref="AllowSpecialCharactersExpressionTransformer"/>
        /// before executing <c cref="PartialEvaluatingExpressionTreeProcessor"/>
        /// and other default processors. 
        /// </summary>
        internal static IExpressionTreeProcessor CreateExpressionTreeProcessor()
        {
            var firstRegistry = new ExpressionTransformerRegistry();
            firstRegistry.Register(new AllowSpecialCharactersExpressionTransformer());

            var processor = ExpressionTreeParser.CreateDefaultProcessor(ExpressionTransformerRegistry.CreateDefault());
            processor.InnerProcessors.Insert(0, new TransformingExpressionTreeProcessor(firstRegistry));
            return processor;
        }
コード例 #8
0
        /// <summary>
        /// Creates an <c cref="IExpressionTreeProcessor"/> that will execute
        /// <c cref="AllowSpecialCharactersExpressionTransformer"/>
        /// before executing <c cref="PartialEvaluatingExpressionTreeProcessor"/>
        /// and other default processors.
        /// </summary>
        internal static IExpressionTreeProcessor CreateExpressionTreeProcessor()
        {
            var firstRegistry = new ExpressionTransformerRegistry();

            firstRegistry.Register(new AllowSpecialCharactersExpressionTransformer());

            var processor = ExpressionTreeParser.CreateDefaultProcessor(ExpressionTransformerRegistry.CreateDefault());

            processor.InnerProcessors.Insert(0, new TransformingExpressionTreeProcessor(firstRegistry));
            return(processor);
        }
コード例 #9
0
        internal static Func <Expression, Expression> CreatePreTransformer(IExpressionTransformerRegistrar expressionTransformerRegistrar)
        {
            var preTransformerRegistry = new ExpressionTransformerRegistry();

            // NH-3247: must remove .Net compiler char to int conversion before
            // parameterization occurs.
            preTransformerRegistry.Register(new RemoveCharToIntConversion());
            expressionTransformerRegistrar?.Register(preTransformerRegistry);

            return(new TransformingExpressionTreeProcessor(preTransformerRegistry).Process);
        }
コード例 #10
0
        /// <summary>
        ///     The create query parser.
        /// </summary>
        /// <returns>
        ///     The <see cref="IQueryParser" />.
        /// </returns>
        public static IQueryParser CreateQueryParser()
        {
            CompoundNodeTypeProvider nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider();
            var earlyTransformerRegistry = new ExpressionTransformerRegistry();

            earlyTransformerRegistry.Register(new DateTimeEarlyExpressionTransformer());
            CompoundExpressionTreeProcessor processor = CreateDefaultProcessor(earlyTransformerRegistry);
            var expressionTreeParser = new ExpressionTreeParser(nodeTypeProvider, processor);
            var queryParser          = new QueryParser(expressionTreeParser);

            return(queryParser);
        }
コード例 #11
0
        public void RegisteredTransformerCount()
        {
            Assert.That(_registry.RegisteredTransformerCount, Is.EqualTo(0));

            var transformerStub = CreateTransformerStub <Expression> (1, ExpressionType.Constant);

            _registry.Register(transformerStub);

            Assert.That(_registry.RegisteredTransformerCount, Is.EqualTo(1));

            _registry.Register(transformerStub);

            Assert.That(_registry.RegisteredTransformerCount, Is.EqualTo(2));

            var transformerStub2 = CreateTransformerStub <Expression> (2, ExpressionType.Equal);

            _registry.Register(transformerStub2);

            Assert.That(_registry.RegisteredTransformerCount, Is.EqualTo(3));
        }
コード例 #12
0
        protected virtual void VisitGroupResultOperator(GroupResultOperator groupResultOperator, QueryModel queryModel)
        {
            _groupingExpressionTransformerRegistry = new ExpressionTransformerRegistry();

            // Add GROUP BY clause for the grouping key
            // And add transformations for any references to the key

            if (groupResultOperator.KeySelector.NodeType == ExpressionType.New)
            {
                // Grouping by a multipart key, so add each key to the GROUP BY clause

                var newExpression = (NewExpression) groupResultOperator.KeySelector;

                foreach (var argument in newExpression.Arguments)                {
                    _queryPartsAggregator.AddGroupByPart(GetN1QlExpression(argument));
                }

                // Use MultiKeyExpressionTransformer to remap access to the Key property

                _groupingExpressionTransformerRegistry.Register(
                    new MultiKeyExpressionTransfomer(_queryGenerationContext.GroupingQuerySource, newExpression));
            }
            else
            {
                // Grouping by a single column

                _queryPartsAggregator.AddGroupByPart(GetN1QlExpression(groupResultOperator.KeySelector));

                // Use KeyExpressionTransformer to remap access to the Key property

                _groupingExpressionTransformerRegistry.Register(
                    new KeyExpressionTransfomer(_queryGenerationContext.GroupingQuerySource, groupResultOperator.KeySelector));
            }

            // Add transformations for any references to the element selector

            if (groupResultOperator.ElementSelector.NodeType == QuerySourceReferenceExpression.ExpressionType)
            {
                _queryGenerationContext.ExtentNameProvider.LinkExtents(
                    ((QuerySourceReferenceExpression) groupResultOperator.ElementSelector).ReferencedQuerySource,
                    _queryGenerationContext.GroupingQuerySource.ReferencedQuerySource);
            }
            else
            {
                throw new NotSupportedException("Unsupported GroupResultOperator ElementSelector Type");
            }
        }
 public void Register(ExpressionTransformerRegistry expressionTransformerRegistry)
 {
     expressionTransformerRegistry.Register(new LikeTransformer());
 }