Example #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();
        }
Example #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();
        }
Example #3
0
 /// <summary>
 /// Initializes an instance of the filter.
 /// </summary>
 /// <param name="selectStatement"></param>
 public SqlExistFilter(SqlSelectBuilder selectStatement)
 {
     this.Statement = selectStatement;
 }