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()); }
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"); } }
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); }
static DateTimeTransformationRegistry() { var registry = new ExpressionTransformerRegistry(); registry.Register(new DateTimeComparisonExpressionTransformer()); Default = registry; }
/// <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; }
/// <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); }
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); }
/// <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); }
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)); }
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()); }