Ejemplo n.º 1
0
        protected override string BuildConditionRValue(QConditionNode node)
        {
            var rValue = base.BuildConditionRValue(node);

            return((node.RValue is Query && ((node.Condition & Conditions.In) != Conditions.In)) ?
                   "(" + rValue + ")" : rValue);
        }
Ejemplo n.º 2
0
 internal static QNode MapQValue(QNode qNode, Func <IQueryValue, IQueryValue> mapFunc)
 {
     if (qNode is QGroupNode)
     {
         var group = new QGroupNode((QGroupNode)qNode);
         for (int i = 0; i < group.Nodes.Count; i++)
         {
             group.Nodes[i] = MapQValue(group.Nodes[i], mapFunc);
         }
         return(group);
     }
     if (qNode is QConditionNode)
     {
         var origCndNode = (QConditionNode)qNode;
         var cndNode     = new QConditionNode(origCndNode.Name,
                                              mapFunc(origCndNode.LValue),
                                              origCndNode.Condition,
                                              mapFunc(origCndNode.RValue));
         return(cndNode);
     }
     if (qNode is QNegationNode)
     {
         var negNode = new QNegationNode((QNegationNode)qNode);
         for (int i = 0; i < negNode.Nodes.Count; i++)
         {
             negNode.Nodes[i] = MapQValue(negNode.Nodes[i], mapFunc);
         }
         return(negNode);
     }
     return(qNode);
 }
Ejemplo n.º 3
0
 public QConditionNode(QConditionNode node)
 {
     Name       = node.Name;
     _LValue    = node.LValue;
     _Condition = node.Condition;
     _RValue    = node.RValue;
 }
Ejemplo n.º 4
0
        protected virtual string BuildCondition(QConditionNode node)
        {
            Conditions condition = node.Condition & (
                Conditions.Equal | Conditions.GreaterThan |
                Conditions.In | Conditions.LessThan |
                Conditions.Like | Conditions.Null
                );
            string lvalue = BuildConditionLValue(node);
            string rvalue = BuildConditionRValue(node);
            string res    = null;

            switch (condition)
            {
            case Conditions.GreaterThan:
                res = String.Format("{0}>{1}", lvalue, rvalue);
                break;

            case Conditions.LessThan:
                res = String.Format("{0}<{1}", lvalue, rvalue);
                break;

            case (Conditions.LessThan | Conditions.Equal):
                res = String.Format("{0}<={1}", lvalue, rvalue);
                break;

            case (Conditions.GreaterThan | Conditions.Equal):
                res = String.Format("{0}>={1}", lvalue, rvalue);
                break;

            case Conditions.Equal:
                res = String.Format("{0}{2}{1}", lvalue, rvalue, (node.Condition & Conditions.Not) != 0 ? "<>" : "=");
                break;

            case Conditions.Like:
                res = String.Format("{0} LIKE {1}", lvalue, rvalue);
                break;

            case Conditions.In:
                res = String.IsNullOrWhiteSpace(rvalue) ? "0=1" : String.Format("{0} IN ({1})", lvalue, rvalue);
                break;

            case Conditions.Null:
                res = String.Format("{0} IS {1} NULL", lvalue, (node.Condition & Conditions.Not) != 0 ? "NOT" : "");
                break;

            default:
                throw new ArgumentException("Invalid conditions set", condition.ToString());
            }

            if ((node.Condition & Conditions.Not) != 0 &&
                (condition & Conditions.Null) == 0 &&
                (condition & Conditions.Equal) == 0)
            {
                return(String.Format("NOT ({0})", res));
            }
            return(res);
        }
Ejemplo n.º 5
0
 protected virtual string BuildConditionRValue(QConditionNode node)
 {
     if ((node.Condition & Conditions.In) == Conditions.In && IsMultivalueConst(node.RValue))
     {
         var multiValue = ((QConst)node.RValue).Value as IList;
         return(BuildValue(multiValue));
     }
     return(BuildValue(node.RValue));
 }
Ejemplo n.º 6
0
        protected override string BuildConditionLValue(QConditionNode node)
        {
            var lValue = base.BuildConditionLValue(node);

            return((node.LValue is Query) ? "(" + lValue + ")" : lValue);
        }
Ejemplo n.º 7
0
 protected virtual string BuildConditionRValue(QConditionNode node)
 {
     return(BuildValue(node.RValue));
 }