public AddTable ( string tableName ) : void | ||
tableName | string | The name of the table in the database to query from. |
Résultat | void |
private static void AddSourceToClause(FromClause clause, IFromSourceNode source) { string alias = null; if (source.Alias != null) alias = source.Alias.Text; if (source is FromTableSourceNode) { var tableSource = (FromTableSourceNode)source; clause.AddTable(alias, tableSource.TableName.Name); } else if (source is FromQuerySourceNode) { var querySource = (FromQuerySourceNode)source; var queryExpression = (SqlQueryExpression) Build(querySource.Query); clause.AddSubQuery(alias, queryExpression); } }
public static FromClause Build(PlSqlParser.FromClauseContext context) { if (context == null) return null; var clause = new FromClause(); var list = context.tableRefList(); if (list.IsEmpty) throw new ParseCanceledException("No source set in FROM clause"); var tableRefs = list.tableRef().Select(FormTableRef); bool joinSeen = false; bool first = true; foreach (var tableRef in tableRefs) { if (joinSeen) throw new ParseCanceledException("Invalid join clause"); var source = tableRef.Source; if (source.SubQuery != null) { clause.AddSubQuery(source.Alias, source.SubQuery); } else if (source.TableName != null) { clause.AddTable(source.Alias, source.TableName); } foreach (var joinNode in tableRef.Join) { var joinSource = joinNode.Source; if (joinSource.SubQuery != null) { clause.AddSubQuery(joinSource.Alias, joinSource.SubQuery); } else if (joinSource.TableName != null) { clause.AddTable(joinSource.Alias, joinSource.TableName); } clause.Join(joinNode.JoinType, joinNode.OnExpression); joinSeen = true; } if (!first && !joinSeen) { clause.Join(JoinType.Inner, null); } first = false; } return clause; }