当前位置: 首页>>代码示例>>C#>>正文


C# SqlBuilder.Append方法代码示例

本文整理汇总了C#中SqlBuilder.Append方法的典型用法代码示例。如果您正苦于以下问题:C# SqlBuilder.Append方法的具体用法?C# SqlBuilder.Append怎么用?C# SqlBuilder.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlBuilder的用法示例。


在下文中一共展示了SqlBuilder.Append方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override void Execute(IDatabase database)
        {
            if (!Table.Columns.Any())
            {
                throw new InvalidOperationException("Cannot create a table with no columns.");
            }

            var sql = new SqlBuilder();
            sql.Append("if not ({0}) begin create table {1} (",
                GetTableExistsSql(database, Table.Name),
                database.FormatTableNameAndEscape(Table.Name));

            var i = 0;
            foreach (var column in Table.Columns)
            {
                var sqlBuilder = new SqlBuilder()
                    .Append(i > 0, ",")
                    .Append(database.Escape(column.Name))
                    .Append(GetColumnSqlType(column, i.ToString()));

                sql.Append(sqlBuilder);
                i++;
            }

            sql.Append("); end;");

            database.RawExecute(sql.ToString());
        }
开发者ID:asgerhallas,项目名称:HybridDb,代码行数:28,代码来源:CreateTable.cs

示例2: Execute

        public override void Execute(IDatabase database)
        {
            var sql = new SqlBuilder();
            sql.Append("alter table {0} add {1}", database.FormatTableNameAndEscape(Tablename), database.Escape(Column.Name));
            sql.Append(GetColumnSqlType(Column));

            database.RawExecute(sql.ToString());
        }
开发者ID:dcga,项目名称:HybridDb,代码行数:8,代码来源:AddColumn.cs

示例3: TopClause

 /// <summary>
 /// Creates a TopClause with the given topCount and withTies.
 /// </summary>
 /// <param name="topCount"></param>
 /// <param name="withTies"></param>
 internal TopClause(int topCount, bool withTies)
 {
   SqlBuilder sqlBuilder = new SqlBuilder();
   sqlBuilder.Append(topCount.ToString(CultureInfo.InvariantCulture));
   this.topCount = sqlBuilder;
   this.withTies = withTies;
 }
开发者ID:yingfangdu,项目名称:SQLiteNet,代码行数:12,代码来源:TopClause.cs

示例4: SkipClause

 /// <summary>
 /// Creates a SkipClause with the given skipCount.
 /// </summary>
 /// <param name="skipCount"></param>
 internal SkipClause(int skipCount)
 {
     SqlBuilder sqlBuilder = new SqlBuilder();
     sqlBuilder.Append(skipCount.ToString(CultureInfo.InvariantCulture));
     this.skipCount = sqlBuilder;
 }
开发者ID:yingfangdu,项目名称:SQLiteNet,代码行数:10,代码来源:SkipClause.cs

示例5: QueryVersions

        public SqlQuery QueryVersions(DatasetInfo baseTable, DatasetInfo versionedTable, Expression expression)
        {
            var sql = new SqlBuilder(adapter);

            var v = new SchemaObject(versionedTable.Name, "v");

            var a = new SchemaObject(baseTable.Name, "a");

            sql.Append("SELECT ");

            sql.WriteColumns(versionedTable.Members, prefix: "v"); // mutable values, primary keys, ...

            sql.Append(", ");

            sql.WriteColumns(baseTable.Members.Where(m => !m.IsVersion && !m.IsKey && !m.IsMutable), prefix: "a"); // immutable values from base table

            sql.From(v); // SELECT from v

            var keyName = baseTable.PrimaryKey[0].Name;

            // join the base (immutable) values with the versioned values
            sql.InnerJoin(
                baseTable       : v,        // versioned values
                joinedTable     : a,        // base values
                baseColumn      : keyName, 
                joinedColumn    : keyName
            );

            sql.Where(Expand(expression, baseTable)); 

            return new SqlQuery(sql.ToString(), sql.Parameters);
        }
开发者ID:carbon,项目名称:Data,代码行数:32,代码来源:SqlGenerator.cs

示例6: FirstClause

		/// <summary>
		/// Creates a TopClause with the given topCount and withTies.
		/// </summary>
		/// <param name="topCount"></param>
		internal FirstClause(int firstCount)
		{
			SqlBuilder sqlBuilder = new SqlBuilder();
			sqlBuilder.Append(firstCount.ToString(CultureInfo.InvariantCulture));
			_firstCount = sqlBuilder;
		}
开发者ID:nakagami,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:10,代码来源:FirstClause.cs

示例7: Execute

        public override void Execute(IDatabase database)
        {
            var builder = new SqlBuilder();
            var formattedAndEscapedTableName = database.FormatTableNameAndEscape(TableName);
            var escapedColumnName = database.Escape(Column.Name);

            //DROP CONSTRAINTS
            foreach (var constraintName in (database is SqlServerUsingTempTables ? tempTablesConstraintQueries : constraintQueries)
                .Select(x => database.RawQuery<string>(x, new { TableName = database.FormatTableName(TableName), ColumnName = Column.Name }))
                .Select(x => x.SingleOrDefault())
                .Where(x => x != null))
            {
                builder.Append("ALTER TABLE {0} DROP CONSTRAINT {1};", formattedAndEscapedTableName, database.Escape(constraintName));
            }

            builder
                //ALTER TABLE
                .Append(GetAlterTableStatement(formattedAndEscapedTableName, escapedColumnName))

                //DEFAULT CONSTRAINT
                .Append(Column.DefaultValue != null, "ALTER TABLE {0} ADD DEFAULT '{1}' FOR {2};", formattedAndEscapedTableName, Column.DefaultValue, escapedColumnName)

                //PRIMAY KEY
                .Append(Column.IsPrimaryKey, @"ALTER TABLE {0} ADD PRIMARY KEY ({1});", formattedAndEscapedTableName, escapedColumnName);

            database.RawExecute(builder.ToString());
        }
开发者ID:asgerhallas,项目名称:HybridDb,代码行数:27,代码来源:ChangeColumnType.cs

示例8: GetAlterTableStatement

        string GetAlterTableStatement(string formattedAndEscapedTableName, string escapedColumnName)
        {
            var builder = new SqlBuilder();
            var sqlColumn = SqlTypeMap.Convert(Column);

            builder
                .Append("ALTER TABLE {0} ALTER COLUMN {1}", formattedAndEscapedTableName, escapedColumnName)
                .Append(new SqlParameter {DbType = sqlColumn.DbType}.SqlDbType.ToString())
                .Append(sqlColumn.Length != null, "(" + sqlColumn.Length + ")")
                .Append(Column.Nullable, "NULL").Or("NOT NULL")
                .Append(";");

            return builder.ToString();
        }
开发者ID:asgerhallas,项目名称:HybridDb,代码行数:14,代码来源:ChangeColumnType.cs


注:本文中的SqlBuilder.Append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。