private void WriteExpression(ConditionNode node, XmlWriter writer)
        {
            writer.WriteStartElement("Expression");
            var fieldNode = ((FieldNode)node.Left);
            writer.WriteAttributeString("Column", fieldNode.Field);
            writer.WriteAttributeString("FieldType", fieldNode.FieldType.ToString());
            writer.WriteAttributeString("Operator", node.ToOperator());
            var constantNode = (ConstantNode)node.Right; //All Nodes to Right should be Constants.
            var strValue = Convert.ToString(constantNode.Value, CultureInfo.InvariantCulture);
//                if (node.Condition == Condition.NotEquals && string.IsNullOrEmpty(strValue))
//                    return null;
            writer.WriteElementString(constantNode.DataType.ToString(), strValue);
            writer.WriteEndElement();
        }
        public void ConvertInToOrs()
        {
            var output = new List <Node>();

            for (int i = 0; i < this.Count; i++)
            {
                var node = this[i];
                if (node.NodeType == NodeType.Condition)
                {
                    var condition = (ConditionNode)node;
                    if (condition.Condition == Condition.In)
                    {
                        var array = (ArrayOfValues)condition.Right;
                        output.Add(new OpenBracketNode());
                        foreach (var value in array.Values)
                        {
                            var cNew = new ConditionNode("=");
                            cNew.Left  = condition.Left;
                            cNew.Right = value;
                            output.Add(cNew);

                            output.Add(new OperatorNode("or"));
                        }
                        output.RemoveAt(output.Count - 1); //Remove last or
                        output.Add(new CloseBracketNode());
                    }
                    else
                    {
                        output.Add(node);
                    }
                }
                else
                {
                    output.Add(node);
                }
            }
            this.Clear();
            this.AddRange(output);
        }
 private Node SetState(CursorState state, string word)
 {
     Node node = null;
     if (state != currentState)
     {
         if (state == CursorState.FieldName)
         {
             node = new FieldNode(word);
         }
         if (state == CursorState.Condition)
         {
             node = new ConditionNode(word);
         }
         if (state == CursorState.Parameter)
         {
             node = new ParameterNode(word);
         }
         if (state == CursorState.Constant)
         {
             node = new ConstantNode(word);
         }
         if (state == CursorState.ArrayOfValues)
         {
             node = new ArrayOfValues(word);
         }
         if (state == CursorState.OpenBracket)
         {
             node = new OpenBracketNode();
         }
         if (state == CursorState.CloseBracket)
         {
             node = new CloseBracketNode();
         }
         if (state == CursorState.Operator)
         {
             node = new OperatorNode(word);
         }
         if (node != null)
             nodes.Add(node);
         currentState = state;
     }
     return node;
 }