Esempio n. 1
0
        public virtual string BuildExpression(QNode node)
        {
            if (node == null)
            {
                return(null);
            }

            if (node is QRawSqlNode)
            {
                return(((QRawSqlNode)node).SqlText);
            }
            if (node is QGroupNode)
            {
                return(BuildGroup((QGroupNode)node));
            }
            if (node is QConditionNode)
            {
                return(BuildCondition((QConditionNode)node));
            }
            if (node is QNegationNode)
            {
                return(BuildNegation((QNegationNode)node));
            }

            throw new ArgumentException("Cannot build node with such type", node.GetType().ToString());
        }
Esempio 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);
 }
Esempio n. 3
0
File: Query.cs Progetto: vennim/data
 private void SetVarsInternal(QNode node, Action <QVar> setVar)
 {
     if (node is QConditionNode)
     {
         var cndNode = (QConditionNode)node;
         if (cndNode.LValue is QVar)
         {
             setVar((QVar)cndNode.LValue);
         }
         if (cndNode.RValue is QVar)
         {
             setVar((QVar)cndNode.RValue);
         }
     }
     if (node != null)
     {
         foreach (var cNode in node.Nodes)
         {
             SetVarsInternal(cNode, setVar);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the QueryNegationNode that wraps specified node
 /// </summary>
 /// <param name="node">condition node to negate</param>
 public QNegationNode(QNode node)
 {
     SingleNodeList = new QNode[] { node };
 }
Esempio n. 5
0
File: Query.cs Progetto: vennim/data
 /// <summary>
 /// Initializes a new instance of the Query with specified table and condition
 /// </summary>
 /// <param name="table">target table</param>
 /// <param name="condition">conditions root node</param>
 public Query(QTable table, QNode condition)
 {
     _Table    = table;
     Condition = condition;
 }