public static string GetN1QlSelectNewExpression(Expression expression, N1QlQueryGenerationContext queryGenerationContext)
        {
            var visitor = new N1QlExpressionTreeVisitor(queryGenerationContext);

            visitor.VisitSelectNewExpression(expression);
            return(visitor.GetN1QlExpression());
        }
Пример #2
0
        public void StringCompare_EqualToNeg1_ReturnsLessThan()
        {
            var queryGenerationContext = new N1QlQueryGenerationContext()
            {
                MemberNameResolver =
                    new JsonNetMemberNameResolver(new Newtonsoft.Json.Serialization.DefaultContractResolver()),
                MethodCallTranslatorProvider = new DefaultMethodCallTranslatorProvider(),
                Serializer = new Core.Serialization.DefaultSerializer()
            };

            var visitor = new Mock<N1QlExpressionTreeVisitor>(queryGenerationContext)
            {
                CallBase = true
            };

            var string1 = Expression.Constant("A");
            var string2 = Expression.Constant("B");

            BinaryExpression expression = Expression.Equal(
                Expression.Call(
                    typeof(string).GetMethod("Compare", new[] { typeof(string), typeof(string) }),
                    string1,
                    string2
                ),
                Expression.Constant(-1));

            var newExpression = visitor.Object.ConvertStringCompareExpression(expression) as StringComparisonExpression;

            Assert.NotNull(newExpression);
            Assert.AreEqual(ExpressionType.LessThan, newExpression.Operation);
            Assert.AreEqual(string1, newExpression.Left);
            Assert.AreEqual(string2, newExpression.Right);
        }
        protected N1QlExpressionTreeVisitor(N1QlQueryGenerationContext queryGenerationContext)
        {
            if (queryGenerationContext == null)
            {
                throw new ArgumentNullException("queryGenerationContext");
            }

            _queryGenerationContext = queryGenerationContext;
        }
        public static string GetN1QlSelectNewExpression(NewExpression expression, N1QlQueryGenerationContext queryGenerationContext)
        {
            // Ensure that any date/time expressions are properly converted to Unix milliseconds as needed
            expression = (NewExpression)TransformingExpressionTreeVisitor.Transform(expression,
                                                                                    ExpressionTransformers.DateTimeTransformationRegistry.Default);

            var visitor = new N1QlExpressionTreeVisitor(queryGenerationContext);

            visitor.VisitSelectNewExpression(expression);
            return(visitor.GetN1QlExpression());
        }
Пример #5
0
 public N1QlQueryModelVisitor(IMemberNameResolver memberNameResolver, IMethodCallTranslatorProvider methodCallTranslatorProvider,
                              ITypeSerializer serializer)
 {
     _queryGenerationContext = new N1QlQueryGenerationContext()
     {
         //MemberNameResolver = new JsonNetMemberNameResolver(ClusterHelper.Get().Configuration.SerializationSettings.ContractResolver),
         //MethodCallTranslatorProvider = new DefaultMethodCallTranslatorProvider()
         MemberNameResolver           = memberNameResolver,
         MethodCallTranslatorProvider = methodCallTranslatorProvider,
         Serializer = serializer
     };
 }
 public N1QlQueryModelVisitor(IMemberNameResolver memberNameResolver, IMethodCallTranslatorProvider methodCallTranslatorProvider,
     ITypeSerializer serializer)
 {
     _queryGenerationContext = new N1QlQueryGenerationContext()
     {
         //MemberNameResolver = new JsonNetMemberNameResolver(ClusterHelper.Get().Configuration.SerializationSettings.ContractResolver),
         //MethodCallTranslatorProvider = new DefaultMethodCallTranslatorProvider()
         MemberNameResolver = memberNameResolver,
         MethodCallTranslatorProvider = methodCallTranslatorProvider,
         Serializer = serializer
     };
 }
        /// <exception cref="ArgumentNullException"><paramref name="queryGenerationContext"/> is <see langword="null" />.</exception>
        public N1QlQueryModelVisitor(N1QlQueryGenerationContext queryGenerationContext, bool isSubQuery)
        {
            if (queryGenerationContext == null)
            {
                throw new ArgumentNullException("queryGenerationContext");
            }

            _queryGenerationContext = queryGenerationContext;
            _isSubQuery = isSubQuery;

            if (isSubQuery)
            {
                _queryPartsAggregator.QueryType = N1QlQueryType.Subquery;
            }
        }
Пример #8
0
        /// <exception cref="ArgumentNullException"><paramref name="queryGenerationContext"/> is <see langword="null" />.</exception>
        public N1QlQueryModelVisitor(N1QlQueryGenerationContext queryGenerationContext, bool isSubQuery)
        {
            if (queryGenerationContext == null)
            {
                throw new ArgumentNullException("queryGenerationContext");
            }

            _queryGenerationContext = queryGenerationContext;
            _isSubQuery             = isSubQuery;

            if (isSubQuery)
            {
                _queryPartsAggregator.QueryType = N1QlQueryType.Subquery;
            }
        }
 public N1QlQueryModelVisitor(IMemberNameResolver memberNameResolver, IMethodCallTranslatorProvider methodCallTranslatorProvider,
     ITypeSerializer serializer, ILoggerFactory loggerFactory)
 {
     _loggerFactory = loggerFactory;
     Log = _loggerFactory.CreateLogger<N1QlQueryModelVisitor>();
     _queryPartsAggregator = new QueryPartsAggregator(_loggerFactory);
     _queryGenerationContext = new N1QlQueryGenerationContext()
     {
         //MemberNameResolver = new JsonNetMemberNameResolver(ClusterHelper.Get().Configuration.SerializationSettings.ContractResolver),
         //MethodCallTranslatorProvider = new DefaultMethodCallTranslatorProvider()
         MemberNameResolver = memberNameResolver,
         MethodCallTranslatorProvider = methodCallTranslatorProvider,
         Serializer = serializer
     };
 }
        /// <exception cref="ArgumentNullException"><paramref name="queryGenerationContext"/> is <see langword="null" />.</exception>
        public N1QlQueryModelVisitor(N1QlQueryGenerationContext queryGenerationContext, bool isSubQuery, ILoggerFactory loggerFactory)
        {
            _loggerFactory = loggerFactory;
            Log = _loggerFactory.CreateLogger<N1QlQueryModelVisitor>();
            _queryPartsAggregator = new QueryPartsAggregator(_loggerFactory);
            if (queryGenerationContext == null)
            {
                throw new ArgumentNullException("queryGenerationContext");
            }

            _queryGenerationContext = queryGenerationContext;
            _isSubQuery = isSubQuery;

            if (isSubQuery)
            {
                _queryPartsAggregator.QueryType = N1QlQueryType.Subquery;
            }
        }
 protected N1QlExpressionTreeVisitor(N1QlQueryGenerationContext queryGenerationContext)
 {
     QueryGenerationContext = queryGenerationContext ?? throw new ArgumentNullException(nameof(queryGenerationContext));
 }
 public N1QlQueryModelVisitor(N1QlQueryGenerationContext queryGenerationContext)
     : this(queryGenerationContext, false)
 {
 }
Пример #13
0
 public N1QlQueryModelVisitor(N1QlQueryGenerationContext queryGenerationContext) : this(queryGenerationContext, false)
 {
 }
 public N1QlQueryModelVisitor(N1QlQueryGenerationContext queryGenerationContext, ILoggerFactory loggerFactory)
     : this(queryGenerationContext, false, loggerFactory)
 {
 }