public void Render(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteLiteralValue(this.Value); if (this.Alias != null) { writer.WriteSpace(); writer.Write(SqlConstants.AS); writer.WriteSpace(); writer.WriteColumnName(this.Alias); } }
/// <summary> /// Renders the column name, table expression reference, and alias. /// </summary> /// <param name="writer"></param> /// <param name="args"></param> protected override void Render(SqlTextWriter writer, SqlBuildArguments args) { if (this.Aggregate == SqlAggregate.None) { writer.WriteColumnName(this.ColumnName, args.TableName(this.Table), this.Alias); } else { writer.WriteAggregateColumn(this.ColumnName, args.TableName(this.Table), this.Aggregate, this.Alias); } }
/// <summary> /// Renders the raw value to the writer with its alias, if it exists /// </summary> /// <param name="writer"></param> /// <param name="args"></param> public void Render(SqlTextWriter writer, SqlBuildArguments args) { RenderValueExpression(writer, args); if (this.Alias != null) { writer.WriteSpace(); writer.Write(SqlConstants.AS); writer.WriteSpace(); writer.WriteColumnName(this.Alias); } }
void ISqlStatementElement.Render(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteBeginGroup(); writer.WriteColumnName(this.ColumnName, args.TableName(this.Table)); writer.WriteOperator(this.Operator); if (this.EncodeValueAsLiteral) { writer.WriteLiteralValue(this.Value); } else { writer.WriteParameter(args.CreateParameter(this.Value, this.DataType)); } writer.WriteEndGroup(); }
protected override void RenderInternal(SqlTextWriter writer, SqlBuildArguments args) { string s = this.Value; if (s == null) { s = string.Empty; } writer.WriteBeginGroup(); writer.WriteColumnName(this.ColumnName, args.TableName(this.Table)); writer.WriteSpace(); writer.Write(SqlConstants.LIKE); writer.WriteSpace(); writer.WriteParameter(args.CreateParameter(SqlStringMatchFilter.DecorateValue(this.Value, this.Operator), this.DataType)); writer.WriteEndGroup(); }
/// <summary> /// Writes the filter to the specified <see cref="SqlTextWriter"/> and adds any parameters to the specified <see cref="SqlBuildArguments"/>. /// </summary> /// <param name="writer">The instance of <see cref="SqlTextWriter"/> to write the T-SQL statement to.</param> /// <param name="args">An instance of <see cref="SqlBuildArguments"/> to use for parameters.</param> protected override void RenderInternal(SqlTextWriter writer, SqlBuildArguments args) { //TODO: make this impl agnostic bool first = true; if (this.Values == null) { throw new InvalidOperationException(string.Format(ErrorMessage.SqlListFilter_CollectionIsEmpty, this.ColumnName)); } writer.WriteBeginGroup(); writer.WriteColumnName(this.ColumnName, args.TableName(this.Table)); writer.WriteSpace(); if (this.NotInList) { writer.Write(SqlConstants.NOT); writer.WriteSpace(); } writer.Write(SqlConstants.IN); writer.WriteSpace(); writer.WriteBeginGroup(); foreach (var v in this.Values) { if (!first) { writer.Write(","); } else { first = false; } switch (this.DataType) { case System.Data.DbType.String: case System.Data.DbType.StringFixedLength: case System.Data.DbType.AnsiString: case System.Data.DbType.AnsiStringFixedLength: case System.Data.DbType.Object: writer.WriteParameter(args.CreateParameter(v.ToString(), this.DataType, this.Size)); break; case System.Data.DbType.Boolean: writer.Write(Convert.ToBoolean(v) ? 1 : 0); break; case System.Data.DbType.Int16: case System.Data.DbType.Int32: case System.Data.DbType.Int64: if (this.UseLiteralNumbers) { writer.Write(Convert.ToInt64(v).ToString()); } else { writer.WriteParameter(args.CreateParameter(v, this.DataType, this.Size)); } break; default: writer.WriteParameter(args.CreateParameter(v, this.DataType, this.Size)); break; } } if (first) { throw new InvalidOperationException(string.Format(ErrorMessage.SqlListFilter_CollectionIsEmpty, this.ColumnName)); } writer.WriteEndGroup(); writer.WriteEndGroup(); }
protected virtual void WriteColumnName(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteColumnName(this.ColumnName, args.TableName(this.Table)); }