Esempio n. 1
0
        void ISqlStatementElement.Render(SqlTextWriter writer, SqlBuildArguments args)
        {
            args.AssignAlias(this.SubQueryTable);

            var subquery       = new SqlSelectBuilder(this.SubQueryTable);
            var subQueryColumn = new SqlColumn(this.SubQueryTable, this.SubQueryColumn);

            subQueryColumn.Aggregate = SqlAggregate.Count;
            subQueryColumn.Alias     = "Cnt";
            subquery.Columns.Add(subQueryColumn);

            foreach (var filter in this.SubQueryFilters)
            {
                subquery.Filters.Add(filter);
            }

            writer.WriteBeginGroup();

            writer.WriteBeginGroup();
            subquery.Render(writer, args);
            writer.WriteEndGroup();

            writer.WriteSpace();
            writer.WriteOperator(this.CountOperator);
            writer.WriteSpace();
            writer.WriteParameter(args.CreateParameter(this.CountValue, System.Data.DbType.Int32));

            writer.WriteEndGroup();
        }
Esempio n. 2
0
        void ISqlStatementElement.Render(SqlTextWriter writer, SqlBuildArguments args)
        {
            writer.WriteBeginGroup();

            writer.WriteColumnName(this.ColumnName, args.TableName(this.Table));
            writer.WriteSpace();

            if (this.Condition == SubQueryMode.NotInList)
            {
                writer.Write(SqlConstants.NOT);
                writer.WriteSpace();
            }

            writer.Write(SqlConstants.IN);

            writer.WriteSpace();

            args.AssignAlias(this.SubQueryTable);

            var builder        = new SqlSelectBuilder(this.SubQueryTable);
            var subQueryColumn = new SqlColumn(this.SubQueryTable, this.SubQueryColumn);

            builder.Columns.Add(subQueryColumn);

            foreach (var filter in this.SubQueryFilters)
            {
                builder.Filters.Add(filter);
            }

            writer.WriteBeginGroup();
            builder.Render(writer, args);
            writer.WriteEndGroup();

            writer.WriteEndGroup();
        }