Exemple #1
0
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            if (node.Method.DeclaringType == typeof(InfluxFunctions))
            {
                if (node.Method.Name == "Count")
                {
                    Clause.Append("COUNT(");
                    Visit(node.Arguments[0]);
                    Clause.Append(")");
                }
                else if (node.Method.Name == "Sum")
                {
                    Clause.Append("SUM(");
                    Visit(node.Arguments[0]);
                    Clause.Append(")");
                }

                _requiresExplicitName = true;

                return(node);
            }
            else
            {
                throw new NotSupportedException($"The method '{node.Method.Name}' on '{node.Method.DeclaringType.FullName}' is not supported in a select clause.");
            }
        }
        protected override void OnMemberFound(MemberInfo member)
        {
            var property = Metadata.PropertiesByClrName[member.Name];

            Clause.Append(property.QueryProtocolEscapedKey)
            .Append(", ");
        }
Exemple #3
0
        protected override void OnMemberFound(MemberInfo member)
        {
            var property = Metadata.PropertiesByClrName[member.Name];

            if (property.Key != InfluxConstants.TimeColumn)
            {
                Clause.Append(property.QueryProtocolEscapedKey);
                _lastColumnName = property.QueryProtocolEscapedKey;
                _foundMember    = true;
            }
        }
Exemple #4
0
 protected override Expression VisitConstant(ConstantExpression node)
 {
     if (node.Value == null)
     {
         Clause.Append("NULL");
     }
     else
     {
         var value = QueryEscape.EscapeFieldOrTag(node.Value);
         Clause.Append(value);
     }
     return(node);
 }
        internal string GetOrderByClause(OrderByClause orderBy)
        {
            Projection = orderBy.Projection;
            _orderBy   = orderBy;

            Visit(_orderBy.Expression);

            Clause.Remove(Clause.Length - 2, 2);

            if (orderBy.IsAscending)
            {
                Clause.Append(" ASC");
            }
            else
            {
                Clause.Append(" DESC");
            }

            return(Clause.ToString());
        }
Exemple #6
0
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            if (node.Method.DeclaringType == typeof(InfluxFunctions))
            {
                if (node.Method.Name == "Now")
                {
                    Clause.Append("now()");
                }
                else if (node.Method.Name == "Count")
                {
                    Clause.Append("COUNT(");
                    Visit(node.Arguments[0]);
                    Clause.Append(")");
                }

                return(node);
            }
            else
            {
                throw new NotSupportedException($"The method '{node.Method.Name}' on '{node.Method.DeclaringType.FullName}' is not supported.");
            }
        }
Exemple #7
0
        private void AddPostColumnString()
        {
            if (_foundMember)
            {
                if (_requiresExplicitName)
                {
                    Clause.Append(" AS ")
                    .Append(_lastColumnName);
                }
            }
            _requiresExplicitName = false;
            _foundMember          = false;

            if (Clause[Clause.Length - 1] == ' ')
            {
                Clause.Remove(Clause.Length - 2, 2);
            }

            if (_foundMember)
            {
                Clause.Append(", ");
            }
        }
Exemple #8
0
        protected override Expression VisitBinary(BinaryExpression b)
        {
            Clause.Append("(");

            // TODO: Support ~=, !~

            Visit(b.Left);

            switch (b.NodeType)
            {
            case ExpressionType.Add:
                Clause.Append(" + ");
                break;

            case ExpressionType.Subtract:
                Clause.Append(" - ");
                break;

            case ExpressionType.Multiply:
                Clause.Append(" * ");
                break;

            case ExpressionType.Divide:
                Clause.Append(" / ");
                break;

            default:
                throw new NotSupportedException($"The binary operator '{b.NodeType}' is not supported in a select clause.");
            }

            Visit(b.Right);

            Clause.Append(")");

            return(b);
        }
Exemple #9
0
        protected override Expression VisitBinary(BinaryExpression b)
        {
            Clause.Append("(");

            // TODO: Support ~=, !~

            Visit(b.Left);

            switch (b.NodeType)
            {
            case ExpressionType.Add:
                Clause.Append(" + ");
                break;

            case ExpressionType.Subtract:
                Clause.Append(" - ");
                break;

            case ExpressionType.Multiply:
                Clause.Append(" * ");
                break;

            case ExpressionType.Divide:
                Clause.Append(" / ");
                break;

            case ExpressionType.AndAlso:
                Clause.Append(" AND ");
                break;

            case ExpressionType.OrElse:
                Clause.Append(" OR ");
                break;

            case ExpressionType.Equal:
                Clause.Append(" = ");
                break;

            case ExpressionType.NotEqual:
                Clause.Append(" <> ");
                break;

            case ExpressionType.LessThan:
                Clause.Append(" < ");
                break;

            case ExpressionType.LessThanOrEqual:
                Clause.Append(" <= ");
                break;

            case ExpressionType.GreaterThan:
                Clause.Append(" > ");
                break;

            case ExpressionType.GreaterThanOrEqual:
                Clause.Append(" >= ");
                break;

            default:
                throw new NotSupportedException($"The binary operator '{b.NodeType}' is not supported");
            }

            Visit(b.Right);

            Clause.Append(")");

            return(b);
        }