public SqlSelectClause gSelectClause(List<Object> selectClauseObjects)
 {
     SqlSelectClause sqlSelect = new SqlSelectClause();
     foreach(var s in selectClauseObjects){
         if (s.GetType().Name == "SqlSelectClause"){
             sqlSelect = s as SqlSelectClause;
         }
     }
     return sqlSelect;
 }
 public string writeSelectClause(
     List<SqlSelectScalarExpression> selectScalarList, 
     List<SqlScalarRefExpression> scalarRefList, 
     List<SqlIdentifier> sqlIdentifierList, 
     List<SqlBinaryScalarExpression> binaryScalarList, 
     List<SqlColumnRefExpression> columnRefList, 
     List<SqlSelectStarExpression> starList, 
     SqlSelectClause sqlSelectClause,
     String selectComment)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         if (starList.Count() != 0)
         {
             sb.Append(" select p );").AppendLine();
         }
         else
         {
             sb.Append(loopSqlSelectScalar(selectScalarList, columnRefList, scalarRefList, binaryScalarList, sqlIdentifierList, sqlSelectClause));
         }
         return sb.ToString();
     }
     catch(Exception ex)
     {
         sb.Append("//" + ex.Message.Replace("\r\n", " ")).AppendLine();
         sb.Append("// " + "SQL code to be interpreted").AppendLine();
         sb.Append("// " + selectComment.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " "));
         return sb.ToString();
     }
 }
 public string loopSqlSelectScalar(
     List<SqlSelectScalarExpression> selectScalarList, 
     List<SqlColumnRefExpression> columnRefList, 
     List<SqlScalarRefExpression> scalarRefList, 
     List<SqlBinaryScalarExpression> binaryScalarList,
     List<SqlIdentifier> sqlIdentifierList, 
     SqlSelectClause sqlSelect)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("select new {");
     if (columnRefList.Count != 0)
     {
         sb.Append(checkColumnRef(selectScalarList, columnRefList));
     }
     sb.Append(checkScalarRef(selectScalarList, scalarRefList));
     sb.Append(checkBinaryScalar(selectScalarList, binaryScalarList, columnRefList,sqlIdentifierList, scalarRefList ));
     sb.Append(isDistinct(sqlSelect));
     return sb.ToString();
 }
 public String isDistinct(SqlSelectClause sqlSelect)
 {
     StringBuilder sb = new StringBuilder();
     if (sqlSelect._isDistinct == "True")
     {
         sb.Append(" }).Distinct();");
     }
     else
     {
         sb.Append(" });");
     }
     return sb.ToString();
 }
 /// <summary>
 /// Checks the xNode name to determine the type of object to be created
 /// Instantiates a new object of type x and adds it to the List of objects
 /// </summary>
 /// <param name="xNode"> a single node </param>
 /// <param name="dict"> a List of Objects </param>
 /// <param name="locationparam"> the location attribute of the current index </param>
 /// <returns> a List of objects with the object of type x added to the list </returns>
 public static List<object> checkTypes(XmlNode xNode, List<object> dict, String locationparam)
 {
     String elementName = xNode.Name;
     if (elementName == "SqlSelectClause")
     {
         SqlSelectClause selectClause = new SqlSelectClause(xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         dict.Add(selectClause);
     }
     if (elementName == "SqlQualifiedJoinTableExpression")
     {
         SqlQualifiedJoinTableExpression sqCompBoolExp = new SqlQualifiedJoinTableExpression(xNode.Attributes[0].Value, xNode.Attributes[1].Value, locationparam);
         dict.Add(sqCompBoolExp);
     }
     if (elementName == "SqlTableRefExpression")
     {
         if (xNode.Attributes.Count == 3)
         {
             SqlTableRefExpression sqlTableRefExp = new SqlTableRefExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
             dict.Add(sqlTableRefExp);
         }
         else
         {
             SqlTableRefExpression sqlTableRefExp = new SqlTableRefExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, "p");
             dict.Add(sqlTableRefExp);
         }
     }
     if (elementName == "SqlObjectIdentifier")
     {
         if (xNode.Attributes.Count == 3)
         {
             SqlObjectIdentifier sqlObjID = new SqlObjectIdentifier(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
             dict.Add(sqlObjID);
         }
         else
         {
             SqlObjectIdentifier sqlObjID = new SqlObjectIdentifier(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
             dict.Add(sqlObjID);
         }
     }
     if (elementName == "SqlConditionClause")
     {
         SqlConditionClause sqlConditCl = new SqlConditionClause(locationparam, xNode.Attributes[0].Value);
         dict.Add(sqlConditCl);
     }
     if (elementName == "SqlComparisonBooleanExpression")
     {
         SqlComparisonBooleanExpression sqlComparBool = new SqlComparisonBooleanExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         dict.Add(sqlComparBool);
     }
     if (elementName == "SqlScalarRefExpression")
     {
         SqlScalarRefExpression sqlScalarRef = new SqlScalarRefExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
         dict.Add(sqlScalarRef);
     }
     if (elementName == "SqlBinaryBooleanExpression")
     {
         SqlBinaryBooleanExpression binaryBoolean = new SqlBinaryBooleanExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         dict.Add(binaryBoolean);
     }
     if (elementName == "SqlLiteralExpression")
     {
         SqlLiteralExpression literalExpression = new SqlLiteralExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
         dict.Add(literalExpression);
     }
     if (elementName == "SqlColumnRefExpression")
     {
         SqlColumnRefExpression columnRefExpression = new SqlColumnRefExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
         dict.Add(columnRefExpression);
     }
     if (elementName == "SqlSelectScalarExpression")
     {
         SqlSelectScalarExpression selectScalarExpression = new SqlSelectScalarExpression(locationparam, xNode.Attributes[0].Value);
         dict.Add(selectScalarExpression);
     }
     if (elementName == "SqlBinaryScalarExpression")
     {
         SqlBinaryScalarExpression binaryScalarExpression = new SqlBinaryScalarExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         dict.Add(binaryScalarExpression);
     }
     if (elementName == "SqlSelectStarExpression")
     {
         SqlSelectStarExpression binaryScalarExpression = new SqlSelectStarExpression(locationparam, xNode.Attributes[0].Value);
         dict.Add(binaryScalarExpression);
     }
     if (elementName == "SqlIdentifier")
     {
         SqlIdentifier sqlIdentifier = new SqlIdentifier(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         dict.Add(sqlIdentifier);
     }
     if (elementName == "SqlOrderByItem")
     {
         SqlOrderByItem orderbyItem = new SqlOrderByItem(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         dict.Add(orderbyItem);
     }
     return dict;
 }
 public static Object getType(XmlNode xNode, string locationparam)
 {
     String elementName = xNode.Name;
     if (elementName == "SqlSelectClause")
     {
         SqlSelectClause selectClause = new SqlSelectClause(xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         return selectClause as Object;
     }
     if (elementName == "SqlQualifiedJoinTableExpression")
     {
         SqlQualifiedJoinTableExpression sqCompBoolExp = new SqlQualifiedJoinTableExpression(xNode.Attributes[0].Value, xNode.Attributes[1].Value, locationparam);
         return sqCompBoolExp as Object;
     }
     if (elementName == "SqlTableRefExpression")
     {
         if (xNode.Attributes.Count == 3)
         {
             SqlTableRefExpression sqlTableRefExp = new SqlTableRefExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
             return sqlTableRefExp as Object;
         }
         else
         {
             SqlTableRefExpression sqlTableRefExp = new SqlTableRefExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, "p");
             return sqlTableRefExp as Object;
         }
     }
     if (elementName == "SqlObjectIdentifier")
     {
         if (xNode.Attributes.Count == 3)
         {
             SqlObjectIdentifier sqlObjID = new SqlObjectIdentifier(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
             return sqlObjID as Object;
         }
         else
         {
             SqlObjectIdentifier sqlObjID = new SqlObjectIdentifier(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
             return sqlObjID as Object;
         }
     }
     if (elementName == "SqlConditionClause")
     {
         SqlConditionClause sqlConditCl = new SqlConditionClause(locationparam, xNode.Attributes[0].Value);
         return sqlConditCl as Object;
     }
     if (elementName == "SqlComparisonBooleanExpression")
     {
         SqlComparisonBooleanExpression sqlComparBool = new SqlComparisonBooleanExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         return sqlComparBool as Object;
     }
     if (elementName == "SqlScalarRefExpression")
     {
         SqlScalarRefExpression sqlScalarRef = new SqlScalarRefExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
         return sqlScalarRef as Object;
     }
     if (elementName == "SqlBinaryBooleanExpression")
     {
         SqlBinaryBooleanExpression binaryBoolean = new SqlBinaryBooleanExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         return binaryBoolean as Object;
     }
     if (elementName == "SqlLiteralExpression")
     {
         SqlLiteralExpression literalExpression = new SqlLiteralExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
         return literalExpression as Object;
     }
     if (elementName == "SqlColumnRefExpression")
     {
         SqlColumnRefExpression columnRefExpression = new SqlColumnRefExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value, xNode.Attributes[2].Value);
         return columnRefExpression as Object;
     }
     if (elementName == "SqlSelectScalarExpression")
     {
         SqlSelectScalarExpression selectScalarExpression = new SqlSelectScalarExpression(locationparam, xNode.Attributes[0].Value);
         return selectScalarExpression as Object;
     }
     if (elementName == "SqlBinaryScalarExpression")
     {
         SqlBinaryScalarExpression binaryScalarExpression = new SqlBinaryScalarExpression(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         return binaryScalarExpression as Object;
     }
     if (elementName == "SqlSelectStarExpression")
     {
         SqlSelectStarExpression binaryScalarExpression = new SqlSelectStarExpression(locationparam, xNode.Attributes[0].Value);
         return binaryScalarExpression as Object;
     }
     if (elementName == "SqlIdentifier")
     {
         SqlIdentifier sqlIdentifier = new SqlIdentifier(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         return sqlIdentifier as Object;
     }
     if (elementName == "SqlOrderByItem")
     {
         SqlOrderByItem orderbyItem = new SqlOrderByItem(locationparam, xNode.Attributes[0].Value, xNode.Attributes[1].Value);
         return orderbyItem as Object;
     }
     return null as Object;
 }