Exemplo n.º 1
0
 public override string LookupPrefix(string ns)
 {
     return(AmlToModelWriter.PrefixFromNamespace(ns));
 }
Exemplo n.º 2
0
        private static IExpression HandleOperator(IExpression op, List <IExpression> output, IServerContext context)
        {
            if (op is LikeOperator like)
            {
                like.Right = output.Pop();
                like.Left  = output.Pop();
                if (like.Right is StringLiteral str)
                {
                    like.Right = PatternParser.SqlServer.Parse(str.Value);
                }
            }
            else if (op is BinaryOperator binOp)
            {
                binOp.Right = output.Pop();
                binOp.Left  = output.Pop();
                if (binOp.Left is PropertyReference prop && binOp.Right is StringLiteral str)
                {
                    binOp.Right = AmlToModelWriter.NormalizeLiteral(prop, str.Value, context, AmlToModelWriter.AllowedTypes.SqlStrings);
                }
            }
            else if (op is UnaryOperator unaryOp)
            {
                unaryOp.Arg = output.Pop();
            }
            else if (op is BetweenOperator between)
            {
                if (!(output.Pop() is AndOperator andOp))
                {
                    throw new NotSupportedException();
                }
                between.Min  = andOp.Left;
                between.Max  = andOp.Right;
                between.Left = output.Pop();

                if (between.Left is PropertyReference prop)
                {
                    if (between.Min is StringLiteral minStr)
                    {
                        between.Min = AmlToModelWriter.NormalizeLiteral(prop, minStr.Value, context, AmlToModelWriter.AllowedTypes.SqlStrings);
                    }
                    if (between.Max is StringLiteral maxStr)
                    {
                        between.Max = AmlToModelWriter.NormalizeLiteral(prop, maxStr.Value, context, AmlToModelWriter.AllowedTypes.SqlStrings);
                    }
                }
            }
            else if (op is IsOperator isOp)
            {
                var right = output.Pop();
                isOp.Left = output.Pop();
                if (right is NotOperator notNullOp && notNullOp.Arg is NullLiteral)
                {
                    isOp.Right = IsOperand.NotNull;
                }
                else if (right is NullLiteral)
                {
                    isOp.Right = IsOperand.Null;
                }
                else
                {
                    throw new NotSupportedException();
                }
            }