private List <string> ParseColumnNamesFromQuery() { var result = SqlParser.ParseColumnNames(QB != string.Empty ? SqlForRead.Replace(QB, "").Replace(QE, "") : SqlForRead); if (TypeInfo.IsArray && result?.Count == 0) { throw new ETLBoxException("Could not parse column names from Sql Query! Please pass a valid TableDefinition to the " + " property SourceTableDefinition with at least a name for each column that you want to use in the source." ); } return(result); }
private List <string> ParseColumnNamesFromSql() { var sql = QB != string.Empty ? SqlForRead.Replace(QB, "").Replace(QE, "") : SqlForRead; var statement = TSQLStatementReader.ParseStatements(sql).FirstOrDefault() as TSQLSelectStatement; List <string> columNames = statement?.Select .Tokens .Where(token => token.Type == TSQL.Tokens.TSQLTokenType.Identifier) .Select(token => token.AsIdentifier.Name) .ToList(); return(columNames); }