コード例 #1
0
ファイル: gsSelectQuery.cs プロジェクト: WiseGus/Wizard-Of-Om
        private void AddColumns(StringBuilder sb)
        {
            if (Columns.Count == 0)
            {
                return;
            }

            sb.AppendLine();
            foreach (gsSelectColumn selCol in Columns)
            {
                if (selCol is gsCaseColumn)
                {
                    gsCaseColumn caseColumn = selCol as gsCaseColumn;
                    caseColumn.QueryName = QryName;

                    sb.Append(caseColumn.ToString());
                }
                else if (selCol is gsSubQueryColumn)
                {
                    gsSelectQuery subQry = (selCol as gsSubQueryColumn).SubQuery;
                    subQry.QryName = $"subQry{GetNextID()}";

                    sb.AppendLine();
                    sb.AppendLine(subQry.ToString());
                    sb.Append($"{QryName}.Columns.Add(new SelectColumn(SqlExpression.SubQuery({subQry.QryName}), {selCol.ColumnAlias.Quoted()}));");
                }
                else
                {
                    sb.Append($"{QryName}.Columns.Add(new SelectColumn({selCol.ToString()}));");
                }
                sb.AppendLine();
            }
        }
コード例 #2
0
ファイル: gsSelectQuery.cs プロジェクト: WiseGus/Wizard-Of-Om
        private void AddBaseTable(StringBuilder sb)
        {
            sb.AppendLine();

            if (FromClause.BaseTable is gsSubQueryFromTerm)
            {
                gsSelectQuery subQry = (FromClause.BaseTable as gsSubQueryFromTerm).SubQuery;
                subQry.QryName = $"subQry{GetNextID()}";

                sb.AppendLine();
                sb.AppendLine(subQry.ToString());
                string subQueryStr = $"FromTerm.SubQuery({subQry.QryName}, {FromClause.BaseTable.TableAlias.Quoted()})";
                sb.Append($"{QryName}.FromClause.BaseTable = {subQueryStr};");
            }
            else
            {
                sb.Append($"{QryName}.FromClause.BaseTable = {FromClause.BaseTable.ToString()};");
            }
            sb.AppendLine();
        }