public SqlSection AddTokenSection(bool isReservedWord, params Token[] tokens) { var section = new SqlSection(this, new SqlToken(isReservedWord, tokens)); Sections.Add(section); return(section); }
private SqlSection AddParenthesisGroup(Token[] tokens, ref int i, SqlSection parent) { var section = new SqlSection(parent); section.Sections.Add(new SqlSection(section, new SqlToken(false, tokens[i]))); parent.Sections.Add(section); for (i++; i < tokens.Length; i++) { if (tokens[i].Type == TokenType.StartParenthesis) { if (IsMatch(tokens, i + 1, "SELECT")) { var query = new SqlQuery(section); AddTokenSection(query, tokens[i]); i++; AddSelect(tokens, ref i, query); section.Sections.Add(query); } else { AddParenthesisGroup(tokens, ref i, section); continue; } } else if (tokens[i].Type == TokenType.EndParenthesis) { AddTokenSection(section, tokens[i]); break; } else if (tokens[i].Type == TokenType.EndOfQuery) { AddTokenSection(parent, tokens[i]); break; } else if (IsQueryStart(tokens[i])) { i--; break; } AddTokenSection(section, tokens[i]); } return(section); }
private void AddTokenSection(SqlSection parent, Token t) { parent.AddTokenSection(IsReservedWord(t), t); }
public SqlGroupBy(SqlSection parent) : base(parent) { }
private SqlSection AddParenthesisGroup(Token[] tokens, ref int i, SqlSection parent) { var section = new SqlSection(parent); section.Sections.Add(new SqlSection(section, new SqlToken(false, tokens[i]))); parent.Sections.Add(section); for (i++; i < tokens.Length; i++) { if (tokens[i].Type == TokenType.StartParenthesis) { if (IsMatch(tokens, i + 1, "SELECT")) { var query = new SqlQuery(section); AddTokenSection(query, tokens[i]); i++; AddSelect(tokens, ref i, query); section.Sections.Add(query); } else { AddParenthesisGroup(tokens, ref i, section); continue; } } else if (tokens[i].Type == TokenType.EndParenthesis) { AddTokenSection(section, tokens[i]); break; } else if (tokens[i].Type == TokenType.EndOfQuery) { AddTokenSection(parent, tokens[i]); break; } else if (IsQueryStart(tokens[i])) { i--; break; } AddTokenSection(section, tokens[i]); } return section; }
public SqlOrderBy(SqlSection parent) : base(parent) { }
public SqlSection AddTokenSection(bool isReservedWord, params Token[] tokens) { var section = new SqlSection(this, new SqlToken(isReservedWord, tokens)); Sections.Add(section); return section; }
//public List<SqlToken> Tokens { get; private set; } public SqlSection(SqlSection parent) { Parent = parent; Sections = new List<SqlSection>(); }
public SqlWhere(SqlSection parent) : base(parent) { }
public SqlFrom(SqlSection parent) : base(parent) { }
public SqlSelect(SqlSection parent) : base(parent) { }
public SqlQuery(SqlSection parent) : base(parent) { }
public SqlSection(SqlSection parent, SqlToken token) { Parent = parent; Token = token; }
//public List<SqlToken> Tokens { get; private set; } public SqlSection(SqlSection parent) { Parent = parent; Sections = new List <SqlSection>(); }
public SqlHaving(SqlSection parent) : base(parent) { }