public void CreateDefault() { MethodInfoBasedMethodCallTransformerRegistry registry = MethodInfoBasedMethodCallTransformerRegistry.CreateDefault(); AssertAllMethodsRegistered(registry, typeof(ContainsMethodCallTransformer)); AssertAllMethodsRegistered(registry, typeof(EndsWithMethodCallTransformer)); AssertAllMethodsRegistered(registry, typeof(IndexOfMethodCallTransformer)); AssertAllMethodsRegistered(registry, typeof(LowerMethodCallTransformer)); AssertAllMethodsRegistered(registry, typeof(RemoveMethodCallTransformer)); AssertAllMethodsRegistered(registry, typeof(ReplaceMethodCallTransformer)); AssertAllMethodsRegistered(registry, typeof(StartsWithMethodCallTransformer)); AssertAllMethodsRegistered(registry, typeof(SubstringMethodCallTransformer)); AssertAllMethodsRegistered(registry, typeof(UpperMethodCallTransformer)); }
public RelinqNorthwindDataProvider() { _manager = new NorthwindConnectionManager(); _context = new NorthwindDataContext(_manager.GetConnectionString()); _resolver = new MappingResolver(_context.Mapping); _retriever = new QueryResultRetriever(_manager, _resolver); _resultOperatorHandlerRegistry = ResultOperatorHandlerRegistry.CreateDefault(); var methodBasedTransformerRegistry = MethodInfoBasedMethodCallTransformerRegistry.CreateDefault(); var nameBasedTransformerRegistry = NameBasedMethodCallTransformerRegistry.CreateDefault(); _methodCallTransformerProvider = new CompoundMethodCallTransformerProvider(methodBasedTransformerRegistry, nameBasedTransformerRegistry); methodBasedTransformerRegistry.Register( typeof(SqlMethods).GetMethod("Like", new[] { typeof(string), typeof(string) }), new LikeMethodCallTransformer()); methodBasedTransformerRegistry.Register(DateDiffDayMethodCallTransformer.SupportedMethods, new DateDiffDayMethodCallTransformer()); foreach (var userDefinedFunction in _context.GetType().GetMethods().Where(mi => mi.IsDefined(typeof(FunctionAttribute), false))) { methodBasedTransformerRegistry.Register(userDefinedFunction, new UserDefinedFunctionTransformer()); } var customNodeTypeRegistry = new MethodInfoBasedNodeTypeRegistry(); customNodeTypeRegistry.Register(new[] { typeof(EntitySet <>).GetMethod("Contains") }, typeof(ContainsExpressionNode)); var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider(); nodeTypeProvider.InnerProviders.Add(customNodeTypeRegistry); var transformerRegistry = ExpressionTransformerRegistry.CreateDefault(); var processor = ExpressionTreeParser.CreateDefaultProcessor(transformerRegistry); var expressionTreeParser = new ExpressionTreeParser(nodeTypeProvider, processor); _queryParser = new QueryParser(expressionTreeParser); _executor = new QueryExecutor(_resolver, _retriever, _resultOperatorHandlerRegistry, _methodCallTransformerProvider, false); }