Esempio n. 1
0
        private string toOrderClause(Ordering clause)
        {
            var locator = _mapping.JsonLocator(clause.Expression);

            return(clause.OrderingDirection == OrderingDirection.Asc
                ? locator
                : locator + " desc");
        }
Esempio n. 2
0
        protected override Expression VisitMember(MemberExpression expression)
        {
            if (expression.Type == typeof(bool))
            {
                var locator = _mapping.JsonLocator(expression);
                var @where  = new WhereFragment($"{locator} = False");
                _callback(@where);
            }

            return(base.VisitMember(expression));
        }
Esempio n. 3
0
        public void ConfigureAggregate(CommandBuilder sql, string @operator)
        {
            var locator = _mapping.JsonLocator(Model.SelectClause.Selector);
            var field   = @operator.ToFormat(locator);

            sql.Append("select ");
            sql.Append(field);
            sql.Append(" from ");
            sql.Append(_mapping.Table.QualifiedName);
            sql.Append(" as d");

            AppendWhere(sql);
        }
Esempio n. 4
0
 /// <summary>
 ///     Returns a locator for the member being queried upon
 /// </summary>
 /// <param name="mapping"></param>
 /// <param name="expression"></param>
 /// <returns></returns>
 protected virtual string GetLocator(IQueryableDocument mapping, MethodCallExpression expression)
 {
     if (!expression.Method.IsStatic && expression.Object != null && expression.Object.NodeType != ExpressionType.Constant)
     {
         // x.member.Equals(...)
         return(mapping.JsonLocator(expression.Object));
     }
     if (expression.Arguments[0].NodeType == ExpressionType.Constant)
     {
         // string.Equals("value", x.member)
         return(mapping.JsonLocator(expression.Arguments[1]));
     }
     // string.Equals(x.member, "value")
     return(mapping.JsonLocator(expression.Arguments[0]));
 }
Esempio n. 5
0
        protected override Expression VisitMember(MemberExpression expression)
        {
            if (expression.Type == typeof(bool))
            {
                var locator        = _mapping.JsonLocator(expression);
                var whereFragments = new List <IWhereFragment>
                {
                    new WhereFragment($"{locator} IS NULL"),
                    new WhereFragment($"{locator} != ?", true)
                };
                var @where = new CompoundWhereFragment("or", whereFragments.ToArray());
                _callback(@where);
            }

            return(base.VisitMember(expression));
        }
Esempio n. 6
0
        public static string ToOrderClause(this Ordering clause, IQueryableDocument mapping)
        {
            var locator = mapping.JsonLocator(clause.Expression);

            return(clause.OrderingDirection == OrderingDirection.Asc
                ? locator
                : locator + " desc");
        }
Esempio n. 7
0
            protected override Expression VisitMember(MemberExpression expression)
            {
                if (expression.Type == typeof(bool))
                {
                    var locator = _mapping.JsonLocator(expression);
                    var where = new WhereFragment("{0} = True".ToFormat(locator), true);
                    _register.Peek()(where);
                    return(null);
                }

                return(base.VisitMember(expression));
            }
Esempio n. 8
0
 /// <summary>
 ///     Returns a locator for the member being queried upon
 /// </summary>
 /// <param name="mapping"></param>
 /// <param name="expression"></param>
 /// <returns></returns>
 protected virtual string GetLocator(IQueryableDocument mapping, MethodCallExpression expression)
 {
     if (!expression.Method.IsStatic && expression.Object != null && expression.Object.NodeType != ExpressionType.Constant)
     {
         // x.member.Equals(...)
         return mapping.JsonLocator(expression.Object);
     }
     if (expression.Arguments[0].NodeType == ExpressionType.Constant)
     {
         // string.Equals("value", x.member)
         return mapping.JsonLocator(expression.Arguments[1]);
     }
     // string.Equals(x.member, "value")
     return mapping.JsonLocator(expression.Arguments[0]);
 }