コード例 #1
0
 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);
     }
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
ファイル: SqlRawColumn.cs プロジェクト: jusbuc2k/Csg.Data
        /// <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);
            }
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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();
        }
コード例 #6
0
ファイル: SqlListFilter.cs プロジェクト: jusbuc2k/Csg.Data
        /// <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();
        }
コード例 #7
0
 protected virtual void WriteColumnName(SqlTextWriter writer, SqlBuildArguments args)
 {
     writer.WriteColumnName(this.ColumnName, args.TableName(this.Table));
 }