void ISqlStatementElement.Render(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteBeginGroup(); writer.WriteColumnName(this.LeftColumnName, args.TableName(this.LeftTable)); writer.WriteOperator(this.Operator); writer.WriteColumnName(this.RightColumnName, args.TableName(this.RightTable)); writer.WriteEndGroup(); }
/// <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 portion of the SQL statement that will be used as the value. /// </summary> /// <param name="writer"></param> /// <param name="args"></param> protected override void RenderValueExpression(SqlTextWriter writer, SqlBuildArguments args) { var expr = this.Expression; expr = expr.Replace("{0}", args.TableName(this.Table)); if (_referenceTables != null && _referenceTables.Count > 0) { for (var i = 0; i < _referenceTables.Count; i++) { expr = expr.Replace(string.Concat("{", i + 1, "}"), args.TableName(_referenceTables[i])); } } writer.WriteBeginGroup(); writer.Write(expr); writer.WriteEndGroup(); }
void ISqlStatementElement.Render(SqlTextWriter writer, SqlBuildArguments args) { string[] resolvedArguments = new string[0]; if (this.Arguments != null) { resolvedArguments = this.Arguments.Select(arg => { if (arg is ISqlTable table) { return(writer.FormatQualifiedIdentifierName(args.TableName(table))); } else if (arg is System.Data.Common.DbParameter dbParam) { return(string.Concat("@", dbParam.ParameterName)); } else if (arg is DbParameterValue paramValue) { return(string.Concat("@", args.CreateParameter(paramValue.ParameterName, paramValue.DbType, paramValue.Size))); } else if (arg is string) { return(string.Concat("@", args.CreateParameter(arg.ToString(), System.Data.DbType.String))); } else { return(string.Concat("@", args.CreateParameter(arg, System.Data.DbType.String))); } }).ToArray(); } writer.WriteBeginGroup(); writer.Write(string.Format(this.SqlText, resolvedArguments)); writer.WriteEndGroup(); }
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(); }
public void Render(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteBeginGroup(); writer.WriteColumnName(this.ColumnName, args.TableName(this.Table)); writer.WriteOperator(this.Operator); writer.Write(this.ParameterName); writer.WriteEndGroup(); }
protected override void RenderInternal(SqlTextWriter writer, SqlBuildArguments args) { //TODO: Make this impl agnostic writer.WriteBeginGroup(); writer.WriteColumnName(this.ColumnName, args.TableName(this.Table)); writer.Write((this.IsNull) ? " IS NULL" : " IS NOT NULL"); writer.WriteEndGroup(); }
protected override void RenderInternal(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteBeginGroup(); writer.Write(this.CommandText.TrimEnd(new char[] { '\r', '\n', ';', ' ', '\t' })); writer.WriteEndGroup(); writer.WriteSpace(); writer.Write(SqlConstants.AS); writer.WriteSpace(); writer.Write(SqlDataColumn.Format(args.TableName(this))); }
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(); }
protected override void RenderInternal(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteTableName(this.TableName, args.TableName(this)); }
/// <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(); }
/// <summary> /// Renders the entire SQL statement to the writer. /// </summary> /// <param name="writer"></param> /// <param name="args"></param> protected override void Render(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteRankOver(this.ColumnName, args.TableName(this.Table), this.Aggregate, this.Alias, this.RankDescending); }
protected override void WriteColumnName(SqlTextWriter writer, SqlBuildArguments args) { //TODO: This is causing left-side casting in a filter, which is awful. writer.WriteCast(this.ColumnName, "date", args.TableName(this.Table)); }
protected virtual void WriteColumnName(SqlTextWriter writer, SqlBuildArguments args) { writer.WriteColumnName(this.ColumnName, args.TableName(this.Table)); }