コード例 #1
0
ファイル: DBSource.cs プロジェクト: SipanOhanyan/etlbox
        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);
        }
コード例 #2
0
        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);
        }