public void Visit(LessThanOrEqualsOperator op)
 {
     _conditionWriter.WriteStartElement("le");
     op.Left.Visit(this);
     op.Right.Visit(this);
     _conditionWriter.WriteEndElement();
 }
Example #2
0
 public virtual IExpression Clone(LessThanOrEqualsOperator op)
 {
     return(new LessThanOrEqualsOperator()
     {
         Left = CloneAndReturn(op.Left),
         Right = CloneValue(op.Left, op.Right)
     }.Normalize());
 }
Example #3
0
 public virtual void Visit(LessThanOrEqualsOperator op)
 {
     AddParenthesesIfNeeded(op, () =>
     {
         op.Left.Visit(this);
         Writer.Write(" <= ");
         op.Right.Visit(this);
     });
 }
Example #4
0
 public void Visit(LessThanOrEqualsOperator op)
 {
     AddParenthesesIfNeeded(op, () =>
     {
         op.Left.Visit(this);
         WriteEncoded(" le ");
         op.Right.Visit(this);
     });
 }
Example #5
0
 public virtual void Visit(LessThanOrEqualsOperator op)
 {
     op.Left.Visit(this);
     op.Right.Visit(this);
 }
Example #6
0
 void IExpressionVisitor.Visit(LessThanOrEqualsOperator op)
 {
     _clone = Clone(op);
 }
        /// <summary>Closes one element and pops the corresponding namespace scope.</summary>
        /// <exception cref="InvalidOperationException">This results in an invalid XML document.</exception>
        /// <exception cref="InvalidOperationException">An <see cref="XmlWriter" /> method was called before a previous asynchronous operation finished. In this case, <see cref="InvalidOperationException" /> is thrown with the message “An asynchronous operation is already in progress.”</exception>
        public override void WriteEndElement()
        {
            if (_stack.Count > 0)
            {
                var value = _buffer.ToString() ?? "";
                _buffer.Length = 0;

                var last = _stack.Pop();
                if (_attrBuffer.TryGetValue(ParameterSubstitution.DateRangeAttribute, out var dateRange) &&
                    ParameterSubstitution.TryDeserializeDateRange(dateRange, out var dateStart, out var dateEnd) &&
                    (dateStart.HasValue || dateEnd.HasValue))
                {
                    var property = (last as BinaryOperator)?.Left ?? (last as BetweenOperator)?.Left;
                    if (property == null)
                    {
                        throw new NotSupportedException();
                    }

                    if (dateStart.HasValue && dateEnd.HasValue)
                    {
                        last = new BetweenOperator()
                        {
                            Left = property,
                            Min  = new DateOffsetLiteral(_context, dateStart.Value, false),
                            Max  = new DateOffsetLiteral(_context, dateEnd.Value, true),
                        }.Normalize();
                    }
                    else if (dateStart.HasValue)
                    {
                        last = new GreaterThanOrEqualsOperator()
                        {
                            Left  = property,
                            Right = new DateOffsetLiteral(_context, dateStart.Value, false)
                        }.Normalize();
                    }
                    else
                    {
                        last = new LessThanOrEqualsOperator()
                        {
                            Left  = property,
                            Right = new DateOffsetLiteral(_context, dateEnd.Value, true)
                        }.Normalize();
                    }
                }
                else
                {
                    if (last is IsOperator isOp)
                    {
                        switch (value)
                        {
                        case "defined":
                            isOp.Right = IsOperand.Defined;
                            break;

                        case "not defined":
                            isOp.Right = IsOperand.NotDefined;
                            break;

                        case "not null":
                            isOp.Right = IsOperand.NotNull;
                            break;

                        case "null":
                            isOp.Right = IsOperand.Null;
                            break;

                        case "":
                            break;

                        default:
                            throw new NotSupportedException();
                        }
                    }
                    else if (last is InOperator inOp)
                    {
                        inOp.Right = ListExpression.FromSqlInClause(value);
                    }
                    else if (last is BetweenOperator betweenOp)
                    {
                        betweenOp.SetMinMaxFromSql(value);
                    }
                    else if (last is PropertyReference property)
                    {
                        if (_stack.OfType <Join>().Last().Right.Joins.Any(j => j.Right.TypeProvider == property))
                        {
                            last = null;
                        }
                        else
                        {
                            last = new EqualsOperator()
                            {
                                Left = property
                            };
                        }
                    }

                    if (!(last is ILogical) && last is BinaryOperator binOp)
                    {
                        if (value == "__now()")
                        {
                            binOp.Right = new Functions.CurrentDateTime();
                        }
                        else if (binOp is LikeOperator)
                        {
                            binOp.Right = AmlLikeParser.Instance.Parse(value);
                        }
                        else
                        {
                            binOp.Right = NormalizeLiteral((PropertyReference)binOp.Left, value, _context);
                        }
                    }
                }

                if (last is BinaryOperator genOp &&
                    genOp.Left is PropertyReference prop &&
                    (prop.Name == "generation" || prop.Name == "id"))
                {
                    Query.Version = new VersionCriteria()
                    {
                        Condition = genOp
                    };
                    if (prop.Name == "id")
                    {
                        AddToCondition(genOp);
                    }
                }